Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake an ActiveX control that sort of looks and acts like a title bar
DescriptionThis example shows how to make an ActiveX control that sort of looks and acts like a title bar in Visual Basic 6. It displays minimize and close pictures and takes appropriate action if you click them. It also maximizes or restores the form if you double click the control, and lets the user drag the form around.
Keywordstitle bar, titlebar, caption, ActiveX control, ActiveX
CategoriesControls, Tips and Tricks, ActiveX
 
Thanks to Noor Abbasi.

This control draws minimize and close pictures and takes appropriate action if you click them. It also maximizes or restores the form if you double click the control, and lets the user drag the form around.

Because you have control over the way the control draws itself, you cna make it look like anything you want.

One trick it uses is declaring a ParentForm variable with the WithEvents keyword so the control can catch the parent form's events. In the ReadProperties event handler, the code sets this reference if it is running at runtime.

See the code for the rest of the details.

 
Private WithEvents ParentForm As Form

Private Sub UserControl_ReadProperties(PropBag As _
    PropertyBag)
            :
    If Ambient.UserMode Then
        Set ParentForm = UserControl.Parent
    End If
End Sub

Private Sub ParentForm_Activate()
    UserControl.BackColor = ActvClr
    Label1.BackColor = ActvClr
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated