求一个有解析的代码,能够直接在VS2010上跑起来的,比如我输入一个现存窗口的名字,可以输出这个窗口所有的控件名,如果可以的话,加上sendMessage或者PostMessage来控制这些控件的内容,不胜感激。
http://blog.csdn.net/jiangqin115/article/details/46957565
#include <windows.h>
BOOL CALLBACK EnumChildProc(HWND hWnd,LPARAM lParam);
void main(int argc, char* argv[])
{
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];
::GetWindowText(hWnd,temp1,255);
wsprintf(temp2,"hwnd:%x text: %s",hWnd,temp1);
MessageBox(NULL,temp2,"cwnd",MB_OK);
return true;
}