Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Get handle of window from caption title


Public Declare Function FindWindow Lib "user32.dll <API_USER32.html>" Alias "FindWindowA" ( ByVal lpClassName As String , ByVal lpWindowName As String ) As Long

'Retrive the window's handle of the specified window's title
Public Function WindowHandle(sTitle As String ) As Long
   WindowHandle = FindWindow(vbNullString, sTitle)
End Function

Private Sub Command1_Click()
   MsgBox WindowHandle( "WindowTitle" ) 'Specify the exact caption of the window
End Sub