why isn't hbWnd getting anything?Code:GetWindowText( FindWindowEx( FindWindowEx( FindWindowEx( FindWindow( "IEFrame", 0), 0, "WorkerW", 0), 0, "ReBarWindow32", 0), 0, "ComboBoxEx32", 0), hbWnd, MAX_PATH );
(Text is in IE's address bar.)
why isn't hbWnd getting anything?Code:GetWindowText( FindWindowEx( FindWindowEx( FindWindowEx( FindWindow( "IEFrame", 0), 0, "WorkerW", 0), 0, "ReBarWindow32", 0), 0, "ComboBoxEx32", 0), hbWnd, MAX_PATH );
(Text is in IE's address bar.)
That is probably the ugliest code I have ever seen. How about you check the return values for the 4 FindWindow() functions?
Yes, and it returns valid! see! What iv'e got now:...
Code:#define WIN32_LEAN_AND_MEAN #include <windows.h> #include <gwc.h> #include <windowsx.h> #include <commctrl.h> #include <mmsystem.h> int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { char hbWnd[MAX_PATH]; HWND hwnd = FindWindowEx( FindWindowEx( FindWindowEx( FindWindowEx( FindWindowEx( FindWindow( "IEFrame", 0), 0, "WorkerW", 0), 0, "ReBarWindow32", 0), 0, "ComboBoxEx32", 0), 0, "ComboBox", 0), 0, "Edit", 0); GetWindowText(hwnd,hbWnd,MAX_PATH); if((hwnd && NULL) || (hwnd == NULL)) MessageBox( 0, "Didn't get 'er! ):<", "stinker!", MB_OK); else MessageBox( 0, hbWnd, "well...", MB_OK); return 0; }
Last edited by Queatrix; 02-14-2006 at 05:29 PM.
If you had read this msdn page carefully you would have noticed this:
Which leads you here, where you will find:If the lpszWindow parameter is not NULL, FindWindowEx calls the GetWindowText function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Remarks section of GetWindowText.
And also, what is the purpose of this?If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string.
[...]
To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.
Code:if((hwnd && NULL)|| (hwnd == NULL))
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared