|
-
August 30th, 2001, 03:55 AM
#1
Sending application to front
Hi,
We have two applications, one for logging information and one DOS application that starts in a DOS-box.
What we want is that the logging application is always the top window when the DOS box is started (the logging application starts with Windows and can't be shutdown by the user).
How can this be done. I know it has something to do with ordering Windows.
Thanks for your time
Jeroen van den Bergh
-
August 30th, 2001, 08:23 AM
#2
Re: Sending application to front
Use the SetWindowPos api:
option Explicit
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()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'set the window position to topmost
SetWindowPos me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub
-
August 30th, 2001, 10:52 AM
#3
Re: Sending application to front
Hi,
This is not what I mean. Both applications are not programmed by me. I want to create an app running in the system tray (that's already done) that checks for the given application names (given from e.g. the command line, so can be variable).
It should be like this:
- App.One is started with Windows startup
- App.Two is started when the user wants to use the application
- The new application that controls the topmost Windows (this is were it's all about)
App.One is not necesseraly the topmost Window when started. When App.Two starts, App.One must become the topmost Window. This should be detected and controlled by the systray app that I want to create.
Jeroen
-
August 30th, 2001, 11:31 AM
#4
Re: Sending application to front
Your systray app will need to get the window handle of App.One somehow so it can send it the message to become the front window. You'll need to use either the EnumWindows API or FindWindow API to locate App.One, etc.
-
September 3rd, 2001, 12:49 PM
#5
Re: Sending application to front
Okay,
That part I figured out myself, but how to do this?
Let's say both applicationnames are variables, how do I search with these API's to find a window or app. that's called like the name given?
Thanks for your support.
Jeroen.
-
September 4th, 2001, 10:09 AM
#6
Re: Sending application to front
option Explicit
private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (byval lpClassName as string, byval lpWindowName as string) as Long
private Sub Command1_Click()
Dim hWnd1 as Long
Dim hWnd2 as Long
Dim strWindow1 as string
Dim strWindow2 as string
strWindow1 = "Form1"
strWindow2 = "Form2"
hWnd1 = FindWindow(vbNullString, strWindow1)
hWnd2 = FindWindow(vbNullString, strWindow2)
MsgBox hWnd1 & " " & hWnd2
'Return value 0 means window not found...
End Sub
-
September 4th, 2001, 10:22 AM
#7
Re: Sending application to front
Thanks for the support. This is just what I needed, it works fine now (in combination with topic found earlier to send a window to the front).
Jeroen van den Bergh
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
|