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)
#include <windows.h>
BOOL CALLBACK enumchildproc (HWND 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 );
Edit handle, 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 the C + + program design.