A small bit of code to make your form stay on top!

By | 2002-06-01

This code will make your form stay on top of any other windows running, just like winamp stays on top.

Original Author: Kevin Nading

Assumptions

just make a new form and make a module and follow instructions below.. if you already have a form and or a module just add the code below to them

Side Effects

do not make a large form stay on top or you will not be able to see the other apps that are open

API Declarations

‘put this stuff in your new module
Declare Function SetWindowPos Lib “user32” (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Global Const conHwndTopmost = -1
Global Const conSwpNoActivate = &H10
Global Const conSwpShowWindow = &H40

Code

'just put this line in your form_load event
SetWindowPos hwnd, conHwndTopmost, 100, 100, 400, 141, conSwpNoActivate Or conSwpShowWindow

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.