Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Keeping a form on top
Message
 
To
09/03/2000 00:12:33
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00343571
Message ID:
00343624
Views:
25
>In VFP a form has the property "AlwaysOnTop" while the forms in VB don't have this. How do I keep a form on top of the other forms even if the other forms below it is clicked?

Try this:
Place in MODULE

Global Const SWP_NOMOVE = 2Global Const SWP_NOSIZE = 1
Global Const HWND_TOPMOST = -1Global Const HWND_NOTOPMOST = -2
Global Const FLOAT = 1, SINK = 0
Public Declare Sub 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)

This is a sub within the module

Sub FloatWindow(X As Integer, action As Integer)

Dim wFlags As Integer, result As Integer
wFlags = SWP_NOMOVE Or SWP_NOSIZE

If action <> 0 Then
' Float
Call SetWindowPos(X, HWND_TOPMOST, 0, 0, 0, 0, wFlags)
Else
' Sink
Call SetWindowPos(X, HWND_NOTOPMOST, 0, 0, 0, 0, wFlags)
End If

End Sub

Code to use -->

'Float code

Dim f as integer
f = Screen.ActiveForm.hWndCall
FloatWindow(f, FLOAT)

'sink code

Dim f as integer
f = Screen.ActiveForm.hWndCall FloatWindow(f, SINK)to sink.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Reply
Map
View

Click here to load this message in the networking platform