Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 21, 1998

Simulate Win95 Taskbar Within Your App

The Windows 95 taskbar (with the Auto Hide check box set) is quite attractive and provides a compact, nonintrusive way to access and organize information. You can easily simulate this functionality in a VB program and provide a useful alternative to a pull-down menu and/or SpeedButton. To set up such a "taskbar" in your VB application, include a control that can act as a container for other controls in your VB form. The PictureBox control looks good and works well; or you can use a Panel or a Frame.

Set the PictureBox's Align and AutoSize properties. The Align property indicates where the taskbar will reside on the form, and the AutoSize property ensures that the PictureBox is sized to fit the contours of its parent form whenever the form is resized.

Set the PictureBox's Visible property to False. Make sure your custom taskbar is not visible until the mouse is moved over a defined "hot" zone on the form. A "hot" zone is a location on the screen defined in X or Y coordinates. You can use these coordinates in any unit of measurement, such as twips or pixels. Set the Parent form's ScaleMode property to the unit of measurement you wish to work in.

Set the Width and/or Height of the PictureBox to appropriately show embedded controls or information. Set up code in the Form's MouseMove event to handle the taskbar. This code aligns the taskbar to the left of the screen:

 'Object		Property		Setting
'------		--------		-------
'Form		Name			FrmTaskBarEx
'			ScaleMode	Pixel

'PictureBox	Name			PicTaskBar
'			Align		Align Left
'			AutoSize		True
'			Visible		False

Private Sub Form_Load()
' Set Width of PictureBox to 1/4 size of Parent form 
' when form is loaded. This is wide enough to show 
' all of the controls I embedded in the PictureBox,
' and will vary with each application.
	PicTaskBar.Width = Me.ScaleWidth / 4
End Sub

Private Sub Form_MouseMove(Button As _
	Integer, Shift As Integer, X As Single, Y As Single)
' When the horizontal mouse position is less 
' than or equal to defined hot zone
' (in this case, horizontal pixel position 4), show taskbar
	If (X <= 4) Then 
		PicTaskBar.Visible = True
		' When the horizontal mouse position is 
		' greater than the width of the 
		' PictureBox, hide taskbar
	ElseIf (X > PicTaskBar.Width) Then
		PicTaskBar.Visible = False
	End If
End Sub
Pete Rodriguez
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date