Click to See Complete Forum and Search --> : form vbmodal
tchyper
May 7th, 2001, 07:10 PM
if my application is running minimized, I want to pop up a form with a message. I've tried with form1.show vbmodal
but it shows behind other running applications (for example: internet explorer), does anyone know how can i show it infront of all other applications?
slcotten
May 7th, 2001, 07:38 PM
Place this in General Declarations or Module (if in module change "Private" to "Public"):
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
private 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)
then place this where you want to show your form:
frmMessage.Show vbModal
Form2.Show vbModal
SetWindowPos frmMessage.hWnd, HWND_TOPMOST, frmMessage.Left, frmMessage.Top, frmMessage.Width, frmMessage.Height, 0
HTH
slcotten
May 8th, 2001, 06:08 AM
The code I gave you before did not work consistantly but this should. Place it in your message form's code:
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
private 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)
private Sub Form_Activate()
SetWindowPos frmMessage.hWnd, HWND_TOPMOST, frmMessage.Left, frmMessage.Top, frmMessage.Width, frmMessage.Height, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub
Hope that works a little better. :-)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.