在 OnInitDialog 函数初始化中 设置
SetWindowText(“子窗口”)
然后根据主窗口句柄枚举
bool CALLBACK EnumChildWindowsPro(HWND h_wnd, LPARAM lParam)
{
if (h_wnd)
{
TCHAR ch[100];
CWnd::FromHandle(h_wnd)->GetWindowText(ch, 100);
if (!_tcscmp(ch,_T("子窗口")))//字符串"子窗口" 是在OnInitDialog时候使用SetWindowText(_T("子窗口"))创建的
{
assert(::IsWindow(h_wnd));
::SendMessage(h_wnd, WM_WSAS, 0, 0);
}
}
}
void CR::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
EnumChildWindows(this->GetSafeHwnd(),EnumChildWindowsPro,0)
}
这样就可以在子窗口类中接收消息了
自己记录一下: