Let the drawing begin!
The control will not be visible at run time but we
want it to have a decent look
in the VB IDE environment, add a icon with 32 by 32 pixels of dimension to
the
Picture property of the User Control.
Change the the fowling subs UserControl_Paint and UserControl_Resize:
Private Sub UserControl_Paint()
'Draw
a 3D raised border on the control using the Win32 API
Dim
rct
As
RECT
'First
retrieve the control's dimensions into a RECT structure
GetClientRect UserControl.hwnd, rct
'Use the DrawEdge
Function to draw the 3D border
DrawEdge UserControl.hdc, rct,
BDR_RAISED, BF_RECT
End Sub
Private Sub UserControl_Resize()
UserControl.Size 32 * Screen.TwipsPerPixelX, 32 * Screen.TwipsPerPixelY
End Sub
We have restricted the User Control size to 32 by 32
pixels so that it cant be resized, and in the UserControl_Paint
sub the DrawEdge function will draw a border around the controls, the size
of the border is defined in a RECT data type
that defines the rectangle our user control occupies, the GetClientRect gets
its size automatically, the RECT data type
basically is equal to getting a rectangle from Top, Left, Height, Width VB
properties. The RECT.Bottom is equal to the Height
less the Top and the RECT.Right is equal to Width less the Left. The Top and
Left are the same as the VB ones.
Its not nice to leave dead icons in the system tray area so we always try to
delete it from the tray are when
our User Control is destroyed, event if the program that uses the control
didn't
Private
Sub UserControl_Terminate()
DeleteFromTray
End Sub
A Dialog box to the world who we are!
Public Function ShowAbout()
MsgBox "MaxTrayCtrl V0.1 By MaximusVB" & vbCrLf & "Build date: 15/04/03" _
& vbCrLf & "Home Page: http://maximusvb.angelcities.com" &
vbCrLf & _
"Email: maximussoftware@hotmail.com", vbOKOnly +
vbInformation, "About"
End
Function
Select Tools, Procedure Attributes, in the name Combo
box select ShowAbout, click in the Advanced
button in the Procedure ID Combo box select AboutBox, click in the OK.
This will make appear a (About) property in the VB properties box and if we
click in it the Show About function
is executed, we mapped that function to be the About box of our control.
[ TrayControl ] [ Create Custom Interface Members ] [ The API Declarations ] [ Code Please! ] [ Let the drawing begin! ] [ The Control in use ]
|