well actually. what ive discovered is this:
when i open up Spy++ and look for the textbox, it has been changed from "trillian display" trillian display to "Your text goes here" trillian display
Now, im not sure whats going on!
But it seems that i have 2 textboxes on this form with the same name and same classname!How do i send a message to the other one?
Yeah that never really works
To find the other one your gonna have to enumerate the child windows. Unfortunately since that uses a callback function there's no real way to tell when the enumeration has finished, so it's a bit hard to incorporate that into a function. I post an example in asec anyway.
If you still the need help, check the application we stripped down for getting all the handles. It has the ability to place text in textboxes or change captions of command buttons etc...
Here's an example of using it, you need a listbox and a command box for this one. This will find the window handles of all the toolbars on the taskbar.
wow thanks penagate. I really appreciate it, but since last post ive figured it out with my own code. Im going to test both, see which one does better.
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Any) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hwndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Any) As Long
'showing window
Public Const WM_SETTEXT = &HC 'Setting text of child window
Public Const WM_GETTEXT = &HD 'Getting text of child window
Public Const WM_GETTEXTLENGTH = &HE
Public VCount As Integer, ICount As Integer
Public SpyHwnd As Long
''''''''''''''''''''''''
Public Function WndEnumProc(ByVal hwnd As Long, ByVal lParam As ListView) As Long
Dim WText As String * 512
Dim bRet As Long, WLen As Long
Dim WClass As String * 50
WLen = GetWindowTextLength(hwnd)
bRet = GetWindowText(hwnd, WText, WLen + 1)
GetClassName hwnd, WClass, 50
If InStr(WClass, "icoPMsgAIM") Or InStr(WClass, "icoPMsgMSN") Or InStr(WClass, "icoPMsgYAHOO") Or InStr(WClass, "icoPMsgICQ") Then
Form1.List1.AddItem hwnd
End If
WndEnumProc = 1
End Function
''''''''''''''''''''''''
Public Function WndEnumChildProc(ByVal hwnd As Long, ByVal lParam As ListView) As Long
Dim bRet As Long
Dim myStr As String * 50
bRet = GetClassName(hwnd, myStr, 50)
'if you want the text for only Edit class then use the if statement:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Any) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Any) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWndParent As Long, _
ByVal hWndChildAfter As Long, _
ByVal lpszClassName As String, _
ByVal lpszWindowText As String) _
As Long
'showing window
Public Const WM_SETTEXT = &HC 'Setting text of child window
Public Const WM_GETTEXT = &HD 'Getting text of child window
Public Const WM_GETTEXTLENGTH = &HE
Public i As Integer
Public VCount As Integer, ICount As Integer
Public SpyHwnd As Long, hWndTextbox As Long
''''''''''''''''''''''''
Public Function WndEnumProc(ByVal hWnd As Long, ByVal lParam As ListView) As Long
Dim WText As String * 512
Dim bRet As Long, WLen As Long
Dim WClass As String * 50
WLen = GetWindowTextLength(hWnd)
bRet = GetWindowText(hWnd, WText, WLen + 1)
GetClassName hWnd, WClass, 50
If InStr(WClass, "icoPMsgAIM") Or InStr(WClass, "icoPMsgMSN") Or InStr(WClass, "icoPMsgYAHOO") Or InStr(WClass, "icoPMsgICQ") Then
Form1.List1.AddItem hWnd
End If
WndEnumProc = 1
End Function
''''''''''''''''''''''''
Public Function WndEnumChildProc(ByVal hWnd As Long, ByVal lParam As ListView) As Long
Dim bRet As Long
Dim myStr As String * 50
bRet = GetClassName(hWnd, myStr, 50)
'if you want the text for only Edit class then use the if statement:
Well you're enumming through the child windows at that point, which means if you have successfully got to that line you have already found your textbox, therefore
lol what are they going to do looking thru my files : )..i dont really care rofl..
I have the classname right, but instead of sending the text to the textbox its sending the text to the textboxes caption?? im not sure how to explain, if you want a screenshot ill send one
Nothing seems to be changing so I guess the text isn't being set... But I doubt that the classname is changing... If you refresh Spy++ does it show "trillian display" or something else after you run the code? If you type something in and you try to get the text does it get it? Are you sure it's the right control you want?
Has someone helped you? Then you can Rate their helpful post.
Oh, wait, it changes the title of the trillian display control... Do a FindWindowEx on the trillian display for the classname "edit"... Maybe there is a textbox inside the trillian display control (like in a frame)?
Has someone helped you? Then you can Rate their helpful post.
Actually that wouldn't work now that I think of it again... If it had any child windows it would have a "+" sign beside it in Spy++
My idea was that FindWindow gets you the hwnd of the main window and with FindWindowEx you can get the handle of a child in a specific window... In a child of a window, you can have another child. So I was thinking that maybe they had a textbox in the trillian display control of theirs and "edit" is the standard classname for a textbox (I think)... So doing a FindWindowEx with the hwnd of the trillian display and looking for a "edit" class, if there was a textbox as a child, you would get the handle of it.
I hope I didn't mix you up
But that won't work and I'm running out of ideas... Only other thing that comes to mind and is a completely other approach is SendKeys (or the keyb_event API)
Has someone helped you? Then you can Rate their helpful post.
i cant believe it wont work, this seems like its all 100% right...im not really into sendkeys..but i guess as a last resort <_<...Is it possible it blocked access to it or something??
It's some sort of their own textbox I assume So it won't accept the same messages as the normal textbox that we're thinking of... I hope someone else can come up with something, although I'm afraid it's not possible...
Has someone helped you? Then you can Rate their helpful post.