Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bring to front from DLL
Message
 
To
14/09/1999 06:20:27
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00264356
Message ID:
00265289
Views:
18
>I've written a replacement for VB's MsgBox, but when called by a DLL it hides behind other windows. I've tried a number of things that should have worked (e.g., SetWindowPos), but nothing seems to. What does work is specifying the foreground window as the parent form when I display my form (i.e., Me.Show vbModal, ParentForm), but I don't always know the parent. With GetForegroundWindow I can get the parent's hWnd, but this doesn't get me the object reference I would need for the Show method.

You said you tried SetWindowPos. Do you have the requested paramaters? SetWindowPos requires specifics values.

In this sample, Command1 set the form to be TopMost and Command2 reset it.
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
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOSIZE = 1
Private Const SWP_NOMOVE = 2

Private lngFlags As Long
Private lngResult As Long

Private Sub Command1_Click()
lngFlags = SWP_NOSIZE Or SWP_NOMOVE
lngResult = SetWindowPos(Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, lngFlags)
End Sub

Private Sub Command2_Click()
lngFlags = SWP_NOSIZE Or SWP_NOMOVE
lngResult = SetWindowPos(Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, lngFlags)
End Sub

Is it working with this now?
É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