MayaP
asked on
Making the background application be a foreground one.
Our Customer wanted to be upgraded from Win NT to Windows 2000.
We have 2 Applications, the Foreground one and the Background one, so to speak. The Foreground one calls the background one that is supposed to display a UI for the User and became an Active. We use an API call SetForegroundWindow for this. It worked well with Win NT. When using Windows 2000, it only shows that UI flashing on a task bar and User has to bring it up manually, if that UI not modal. If UI IS modal, User simply doesn't see it. These 2 applications are VB applications and worked fine in Win NT.
How do we make it work in Win 2000 with minimal efforts? Any ideas?
Thanks!
We have 2 Applications, the Foreground one and the Background one, so to speak. The Foreground one calls the background one that is supposed to display a UI for the User and became an Active. We use an API call SetForegroundWindow for this. It worked well with Win NT. When using Windows 2000, it only shows that UI flashing on a task bar and User has to bring it up manually, if that UI not modal. If UI IS modal, User simply doesn't see it. These 2 applications are VB applications and worked fine in Win NT.
How do we make it work in Win 2000 with minimal efforts? Any ideas?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to help - Thanks.
Wileecoy.
Wileecoy.
In a module copy-paste:
Public 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
Public Const FORMAT_MESSAGE_FROM_SYSTEM
'Constants for topmost.
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
In the usage in Form_Load:
Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
I also added other constants to use.
hth.
Wileecoy.