home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Query about other Applications"
- ClientHeight = 3735
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4680
- LinkTopic = "Form1"
- ScaleHeight = 3735
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton Command1
- Caption = "Start"
- Height = 375
- Left = 1080
- TabIndex = 12
- Top = 3240
- Width = 2415
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- Height = 375
- Index = 5
- Left = 1680
- TabIndex = 11
- Text = "Text1"
- Top = 2520
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- Height = 375
- Index = 4
- Left = 1680
- TabIndex = 10
- Text = "Text1"
- Top = 2040
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- Height = 375
- Index = 3
- Left = 1680
- TabIndex = 9
- Text = "Text1"
- Top = 1560
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- Height = 375
- Index = 2
- Left = 1680
- TabIndex = 8
- Text = "Text1"
- Top = 1080
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- Height = 375
- Index = 1
- Left = 1680
- TabIndex = 7
- Text = "Text1"
- Top = 600
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- Height = 375
- Index = 0
- Left = 1680
- TabIndex = 6
- Text = "Text1"
- Top = 120
- Width = 2775
- End
- Begin VB.Label Label6
- Caption = "Parent Caption:"
- Height = 255
- Left = 120
- TabIndex = 5
- Top = 2640
- Width = 1335
- End
- Begin VB.Label Label5
- Caption = "Parent Class:"
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 2160
- Width = 1335
- End
- Begin VB.Label Label4
- Caption = "Parent Handle:"
- Height = 255
- Left = 120
- TabIndex = 3
- Top = 1680
- Width = 1335
- End
- Begin VB.Label Label3
- Caption = "Window Caption:"
- Height = 255
- Left = 120
- TabIndex = 2
- Top = 1200
- Width = 1335
- End
- Begin VB.Label Label2
- Caption = "Window Class:"
- Height = 255
- Left = 120
- TabIndex = 1
- Top = 720
- Width = 1335
- End
- Begin VB.Label Label1
- Caption = "Window Handle:"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 1335
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- 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 Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
- Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, _
- ByVal yPoint As Long) As Long
- Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
- Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
- (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
- Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
- (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
- Const HWND_TOPMOST = -1
- Const SWP_SHOWWINDOW = &H40
- Private Type POINTAPI
- X As Long
- Y As Long
- End Type
- Private gStop As Boolean
- Private Sub Command1_Click()
- Dim mousePT As POINTAPI
- Dim prevWindow As Long
- Dim curWindow As Long
- Dim X As Long
- Dim Y As Long
- Dim tmpStr As String
- Dim retValue As Long
- Dim parentWnd As Long
- 'Track mouse here
- If Command1.Caption = "Start" Then
-
- Command1.Caption = "Stop"
- gStop = False
- prevWindow = 0
-
- 'Track until user stops
- Do
- 'Stop tracking
- If gStop = True Then Exit Do
-
- Call GetCursorPos(mousePT)
-
- X = mousePT.X
- Y = mousePT.Y
-
- 'Get window under mouse
- curWindow = WindowFromPoint(X, Y)
-
- If curWindow <> prevWindow Then
-
- tmpStr = String$(256, " ")
- prevWindow = curWindow
-
- retValue = GetClassName(curWindow, tmpStr, 255)
- tmpStr = Left$(tmpStr, InStr(tmpStr, vbNullChar) - 1)
-
- Text1(0).Text = curWindow
- Text1(1).Text = tmpStr
-
- retValue = GetWindowText(curWindow, tmpStr, 255)
- Text1(2).Text = tmpStr
-
- 'Get parent window
- parentWnd = GetParent(curWindow)
-
- retValue = GetClassName(parentWnd, tmpStr, 255)
- 'tmpStr = Left$(tmpStr, InStr(tmpStr, vbNullChar) - 1)
-
- Text1(3).Text = parentWnd
- Text1(4).Text = tmpStr
-
- retValue = GetWindowText(parentWnd, tmpStr, 255)
- Text1(5).Text = tmpStr
-
- End If
-
-
- DoEvents
-
- Loop
-
-
- 'Stop tracking the mouse
- Else
- Command1.Caption = "Start"
- gStop = True
- End If
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- gStop = True
- End Sub
- Private Sub Form_Load()
- Dim retValue As Long
- If Command1.Caption = "Start" Then
- gStop = False
- 'Command1.Caption = "Stop"
- retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.CurrentX, Me.CurrentY, _
- Me.Width, Me.Height, SWP_SHOWWINDOW)
-
- Else
- gStop = True
- Command1.Caption = "Start"
- End If
- End Sub
-