jlbryant1024
asked on
Findwindow Classes
I have created a little app, that will find a window then find the controls on that form.
I can find the window fine, but i have two text boxes on the form, and of course the class name is thundertextbox well , i have to text boxes, i am able to get the text from the text2 box but how do i make it get the text from the text1 box? I seems to only get text from the text box with the highes number.. I know you can put the text in the vbnullstring area BUT they don't contain text so both are blank .
Dim mystr As String * 255
'the below will find multiple of same class names
fwin = FindWindow(vbNullString, "Form1")
fwin1 = FindWindowEx(fwin, 0, "thundertextbox", vbNullString)
'now sendmessage to get the text
Call SendMessage(fwin1, WM_GETTEXT, 255, mystr)
Label1.Caption = mystr
I can find the window fine, but i have two text boxes on the form, and of course the class name is thundertextbox well , i have to text boxes, i am able to get the text from the text2 box but how do i make it get the text from the text1 box? I seems to only get text from the text box with the highes number.. I know you can put the text in the vbnullstring area BUT they don't contain text so both are blank .
Dim mystr As String * 255
'the below will find multiple of same class names
fwin = FindWindow(vbNullString, "Form1")
fwin1 = FindWindowEx(fwin, 0, "thundertextbox", vbNullString)
'now sendmessage to get the text
Call SendMessage(fwin1, WM_GETTEXT, 255, mystr)
Label1.Caption = mystr
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, if your textbox is other than a "ThunderRT6TextBox" class, replace "ThunderRT6TextBox" in the following section of the code above with the exact name of your class:
If wClass = "ThunderRT6TextBox" Then
x = x + 1
If x = 2 Then 'NOTE: you can change x = 1 to get your Text2.text
mystr = wText
End If
End If
If wClass = "ThunderRT6TextBox" Then
x = x + 1
If x = 2 Then 'NOTE: you can change x = 1 to get your Text2.text
mystr = wText
End If
End If
Dim mystr As String * 255
fwin = FindWindow(vbNullString, "Form1")
EnumChildWindows fwin, AddressOf EnumChildWindow, ByVal 0&
The below is correct:
"The code in your command button should be:"
Dim fwin As Long
fwin = FindWindow(vbNullString, "Form1")
EnumChildWindows fwin, AddressOf EnumChildWindow, ByVal 0&
Label1.Caption = mystr