|
-
Oct 30th, 2001, 04:29 AM
#1
Thread Starter
Junior Member
How to find the Caption
I am running some shell command using which i execute some forms or some application, at this point i wanted to read the caption of the running form's caption.
-
Oct 30th, 2001, 07:51 AM
#2
Shell the program and add this code, assuming that the application launced will be the one with focus.
VB Code:
Private Declare Function GetForegroundWindow _
Lib "user32" () As Long
Private Declare Function GetWindowTextLength _
Lib "user32" Alias "GetWindowTextLengthA" (ByVal _
hwnd 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
Private Declare Function GetParent Lib "user32" (ByVal _
hwnd As Long) As Long
Private Function GetActiveWindowTitle(ByVal ReturnParent As Boolean) As String
Dim i As Long
Dim j As Long
i = GetForegroundWindow
If ReturnParent Then
Do While i <> 0
j = i
i = GetParent(i)
Loop
i = j
End If
GetActiveWindowTitle = GetWindowTitle(i)
End Function
Private Function GetWindowTitle(ByVal hwnd As Long) As String
Dim l As Long
Dim s As String
l = GetWindowTextLength(hwnd)
s = Space$(l + 1)
GetWindowText hwnd, s, l + 1
GetWindowTitle = Left$(s, l)
End Function
-
Oct 30th, 2001, 09:56 AM
#3
Matthew: How, and from where, would you execute your code to the get caption of an open window?
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
|