October 21, 2016
Hot Topics:

Making Your Own Custom Control

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

By default, the control name is 'UserControl1'. Change its name to something relevant like 'OnTop'. Change the CanGetFocus property to False and the InvisibleAtRunTime property to True. Give it a nice picture and leave the ToolboxBitmap property to None, unless you feel the desire to give it a meaningless picture!

Open up the code window for the Control, and go to the General Declarations procedure. This code adds a method statement, which makes the program 'normal':

Public Sub MakeNormal(Handle As Long)
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, _
End Sub

Now add this method statement to put the program on top:

Public Sub MakeTopMost(Handle As Long)
SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, _
End Sub

Right, time to compile the control. Click File, Make OnTop.ocx. Now save the project (File, Save Project).

Click File, New Project. Select a Standard EXE file. Click Project, Components. Click on the Browse button. Go to the directory where you made the OCX file and double click on it. Click OK. Draw the control on to the form. Open up the code window for the form. Go to the form's Load procedure. Add this code:

Private Sub Form_Load()
OnTop1.MakeTopMost (Me.hwnd)
End Sub

Or, if you want it to become normal, use:

Private Sub Form_Load()
OnTop1.MakeNormal (Me.hwnd)
End Sub

Run the Project (F5).

Page 2 of 3

Comment and Contribute


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



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

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