请问已经知道某个应用程序的按钮句柄,能否向这个按钮发送BN_CLICKED消息??
我已经枚举了父窗口所有的控件,但是没有办法向按钮发出按下的消息;
//以下是我的代码
CString str[3]={"STL源代码剖析","本","69.5"};
BOOL CALLBACK CSendTextDlg::EnumChildProc (HWND hwnd, LPARAM lParam)
{
char *p;
char buffer[300];
char WindowName[300];
memset(buffer,0,sizeof(WindowName));
memset(buffer,0,sizeof(buffer));
::GetClassName (hwnd, buffer, 300);
::GetWindowText (hwnd,WindowName, 300);
static int index = 0;
if(strcmp(buffer,"Edit")==0)
{
::SendMessage (hwnd, WM_SETTEXT,0,(LPARAM)str[index++].GetBuffer());
index = index % 3;
return 1;
}
if(strcmp(buffer,"Button")==0)
{
::GetWindowText (hwnd,WindowName, 300);
p = strstr(WindowName, "添加记录");
if( p != NULL)
{
::SendMessage (hwnd,BN_CLICKED,0,0);
return 1;
}
}
return 1;
}