A few more, my friend wants to be a small shared software, the main role of software is to prevent users from entering some websites, and his imagine is to get typed URLs from the address bar of IE. If this URL is illegal, you can't enter, code show as below:
HWND HWND = :: FindWindow (_T ("iframe"), null); if (hwnd) {hwnd hwnd2 = :: FindWindowEx (HWND, NULL, _T ("Edit"), NULL);
Char Sz [255]; :: SendMessage (HWND2, WM_GETTEXT, 255, (LPARAM) SZ); AFXMessageBox (SZ);
The results found that the correct result cannot be obtained. From the Spy, the class name is all correct, why can't you get the correct result? After watching his code, I made the following change, I can get the correct result:
HWND HWND = :: FindWindow (_t ("iframe"), null); if (hwnd) {hwnd hwnd2 = :: FindWindowEx (hwnd, null, _t ("workerw"), null); hwnd hWnd3 = :: FindowEx HWND2, NULL, _T ("Rebarwindow32"), NULL); hwnd hwnd4 = :: FindWindowex (HWND3, NULL, _T ("ComboBoxEx32"), NULL); hwnd hwnd5 = :: FindWindowEx (hwnd4, null, _t ("ComboBox "), Null; hwnd hwnd6 = :: FindWindowEx (HWND5, NULL, _T (" Edit "), NULL);
Char SZ [255]; :: SendMessage (HWND6, WM_GETTEXT, 255, (LPARAM) SZ); AfxMessageBox (SZ);}}
The above code does not need me to explain it, this problem is not a big problem, the difficulty is not big, but it may make the beginner do not understand why there is a Handle who can't get a control of a control. In fact, there is nothing to do if you don't do it. What is going on, just need you to analyze carefully.