![]() ![]() |
![]() |
![]() ![]() ![]() ![]() |
Home » Programming » Visual Basic » Always-On-Top Form [Sept, 21 1999] |
Prologue |
Platform : VB 6.
In some cases you need to show your form as an Always-On-Top such as palette window. Always-OnTop form will stay as the top most window in the screen even though it has lost it focus. We can achieve this by using SetWindowPos(...) API and give HWND_TOPMOST for the hWndInsertAfter parameter.
|
Implementation |
Option
Explicit Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _ (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 Private Sub Form_Load() SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE End Sub |
Epilogue |
To set our Form back to as a
non Always-On-Top form we can call SetWindowPos(...)
again and give HWND_NOTOPMOST for the hWndInsertAfter parameter.
|
Home | inHere | Products | Projects
| Programming Stuff Copyright © 1999 AdNet®. All rights reserved. AdNet® is registered to Benni Adham. |