|
-
October 22nd, 2001, 08:52 PM
#1
On top of things
Is there any code to make a form always appear on top of other programs running (ex. Program A is on top of Internet Explorer even after you click Explorer).
-
October 23rd, 2001, 01:54 AM
#2
Re: On top of things
You can use the SetWindowPos API to do this, paste this in a module. Then you can call it from all over the place.
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
'constants for SetWindowPos API
private Const SWP_NOMOVE = 2
private Const SWP_NOSIZE = 1
private Const HWND_TOPMOST = -1
private Const HWND_NOTOPMOST = -2
public Sub SetOnTop(byval hwnd as Long, byval bSetOnTop as Boolean)
Dim lR as Long
If bSetOnTop then
lR = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or _SWP_NOSIZE)
else
lR = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or _SWP_NOSIZE)
End If
End Sub
' Somewhere else, like in the form load event
private Sub Form_Load()
SetOnTop me.Hwnd, true
End Sub
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|