The example in this article describes how C + + obtains information in other program form controls. Share to everyone for your reference. The specific analysis is as follows:
This shows a way to get information about other program form controls,
Use the FindWindow API to find the text box handle and get the text with SendMessage (Wm_gettext)
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The |
#include <windows.h> BOOL CALLBACK enumchildproc (H WND Hwnd,lparam LPARAM); int WINAPI WinMain (hinstance hinstance,hinstance hprevinstance,lpstr lpcmdline,int ncmdshow) {char classname[]= Notepad "; HWND Hwnd=::findwindow (classname,null); if (hWnd) {:: Enumchildwindows (hwnd,enumchildproc,0); return 0;} MessageBox (NULL, "fail!", "fail", MB_OK); return 0; BOOL CALLBACK Enumchildproc (HWND hwnd,lparam LPARAM) {char temp1[256],temp2[256];:: GetClassName (hwnd,temp1,255); if ( !::STRCMP (Temp1, "Edit")) {:: SendMessage (hwnd,wm_gettext,sizeof (TEMP2)/sizeof (char), (LPARAM) temp2); Handle to//edit, message, Receive buffer size, receive buffer pointer:: MessageBox (NULL,TEMP2, "get", MB_OK); return 0; }:: wsprintf (Temp2, "ClassName:%s", TEMP1); MessageBox (NULL,TEMP2, "CWnd", MB_OK); return true; } |
I hope this article will help you with your C + + programming.