Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i keep my vb form permanantly on the screen

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How can i keep my vb form permanantly on the screen even if other application is opened. I want my application form to be always on top of any other application .Please help me
 
Try using SetWindowPos:
Code:
Private 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

Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2

Dim i As Long

'Force Form On Top
i = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

'Remove Forced Setting
i = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
The only thing that will go over this is another form that uses this function. A good example would be Task Manager.

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top