|
-
Dec 8th, 2000, 10:02 AM
#1
Thread Starter
New Member
I know how to keep a window on top if it is in the same app
as the code (using API calls), and I know how to shell to
an app, but I don't know how to keep a window from an app
that isn't the the one with the code in on top.
Any ideas, anyone?
-
Dec 8th, 2000, 11:50 AM
#2
Use the SetWindowPos api function, same as with making your own form on top.
Code:
'Tip by Sam Huggill
Private Declare Function SetWindowPos Lib "user32" (ByVal _
hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As _
Long, y, 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_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
'Resets the windows position in the ZOrder
Private Sub MakeNormal(lngHwnd As Long)
SetWindowPos lngHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
'Places the window at the top of the ZOrder
'and keeps it there
Private Sub MakeTopMost(lngHwnd As Long)
SetWindowPos lngHwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
-
Dec 11th, 2000, 05:08 AM
#3
Thread Starter
New Member
I _know_ how to use SetWindowPos, I don't know how to get the hWnd for a window that is not part of the program.
-
Dec 11th, 2000, 07:10 AM
#4
Use the FindWindow api function.
Code:
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Private Sub Command1_Click()
'hWin = FindWindow(Class, Caption)
hWin = FindWindow("SciCalc", "Calculator")
If hWin <> 0 Then Msgbox "hWnd: " & hWin
End Sub
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
|