Set Window on top using vb6

Description:
This code shows how to set your window on the top of other windows. Add two command buttons command1 and command2. Clicking command1 sets your window on the top and clicking command2 cancels the effect.

Code:

Advanced usage:

You can add a timer and set the interval to a short time (say 1), Now you can add the code in the command1_click event to timer1_timer event. So your code will always be on the top. But this is not needed. For example even if window is already on the top, this codes again calls the SetWindowPos a number of times (1000 times in a second). To avoid this you can add the following declaration to your code

Now paste the following code in your timer1_timer event

Now the code checks whether any other window is on the top, if yes it set the window on top.

Leave a Reply

Your email address will not be published. Required fields are marked *