home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Query about other Applications"
- ClientHeight = 3675
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4905
- LinkTopic = "Form1"
- ScaleHeight = 3675
- ScaleWidth = 4905
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton Command1
- Caption = "Start"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 465
- Left = 3120
- TabIndex = 12
- Top = 3105
- Width = 1665
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Index = 5
- Left = 1995
- TabIndex = 11
- Top = 2550
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Index = 4
- Left = 1995
- TabIndex = 10
- Top = 2070
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Index = 3
- Left = 1995
- TabIndex = 9
- Top = 1590
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Index = 2
- Left = 1995
- TabIndex = 8
- Top = 1110
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Index = 1
- Left = 1995
- TabIndex = 7
- Top = 630
- Width = 2775
- End
- Begin VB.TextBox Text1
- BackColor = &H80000004&
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Index = 0
- Left = 1995
- TabIndex = 6
- Top = 150
- Width = 2775
- End
- Begin VB.Label Label6
- Caption = "Parent Caption:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 75
- TabIndex = 5
- Top = 2610
- Width = 1815
- End
- Begin VB.Label Label5
- Caption = "Parent Class:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 75
- TabIndex = 4
- Top = 2130
- Width = 1335
- End
- Begin VB.Label Label4
- Caption = "Parent Handle:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 75
- TabIndex = 3
- Top = 1650
- Width = 1815
- End
- Begin VB.Label Label3
- Caption = "Window Caption:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 75
- TabIndex = 2
- Top = 1170
- Width = 1815
- End
- Begin VB.Label Label2
- Caption = "Window Class:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 75
- TabIndex = 1
- Top = 690
- Width = 1815
- End
- Begin VB.Label Label1
- Caption = "Window Handle:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 75
- TabIndex = 0
- Top = 210
- Width = 1815
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- 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, curWindow As Long
- Dim X As Long, 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
- retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.CurrentX, Me.CurrentY, _
- 345, 280, SWP_SHOWWINDOW)
- Else
- gStop = True
- Command1.Caption = "Start"
- End If
- End Sub
-