|
-
May 23rd, 2000, 04:56 AM
#1
Thread Starter
Hyperactive Member
Hi, how can I tell if a window is in the foreground (on top) but not the active window? It wouldn't be covered by any other windows but it doesn't take up the entire screen so another window could be the active one. I just need to know if it can be seen.
Thanks for any help.
-
May 23rd, 2000, 02:12 PM
#2
Fanatic Member
I've seen an API which returns the visible region of a window, I think Kedamans site had it (Class explorer screenshot)
http://www.geocities.com/kedasu/kedacode.html
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 23rd, 2000, 03:51 PM
#3
PowerPoster
Hope this is what you looking for...
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
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 SW_SHOWNORMAL = 1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOP = 0
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Sub Command1_Click()
Dim xhwnd&, dl&
If Len(Text1) = 0 Then Exit Sub
xhwnd = FindWindow(0&, Text1.Text)
If xhwnd <> 0 Then
If Check1.Value Then
dl = ShowWindow(xhwnd, SW_SHOWNORMAL)
dl = SetWindowPos(xhwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
ElseIf Check2.Value Then
dl = ShowWindow(xhwnd, SW_SHOWNORMAL)
dl = SetWindowPos(xhwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
ElseIf Check3.Value Then
dl = ShowWindow(xhwnd, SW_SHOWNORMAL)
dl = SetWindowPos(xhwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
End If
End If
End Sub
Private Sub Form_Load()
Label1.Caption = "Please type the target window name."
End Sub
Private Sub Text1_Change()
end Sub
-
May 24th, 2000, 12:13 AM
#4
Thread Starter
Hyperactive Member
Thanks guys. Paul, I didn't see the API at the site. Chris, the code you gave works great. Thanks again.
Wade
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
|