CWnd 不能直接响应menus, toolbar buttons, and acceler...

    CWnd 不能直接响应menus, toolbar buttons, and accelerator keys产生的消息,这种消息称为Command messages ,Command messages 在MFC应用程序框架下这类消息只能被Command Targets接收到,比如MDI frame window 、Document frame window 、View、Document、Dialog box这些对象。如果要将Command messages发送到CWnd对象,可以这样试试,首先在上述的Command Targets对象中处理Command messages,然后在此消息的处理中向目标CWnd发送消息,这样间接就可以让CWnd接收到消息了。

比如你的程序中  afx_msg void OnSinglestart()消息函数应该在放在MDI frame window 或者Dialog box 中,然后在此次消息函数中调用SendMessage(hwnd,msg,wParam,lParam).

    这是MFC应用程序框架决定的。command message是比较特殊的一种消息,它主要是通过用户点击菜单、工具按钮而成产生的,它并不知道这个消息要发送到何处,所以MS制订一套此类消息传送的机制,那就是先发送到MDI main frame 然后是MDI child frame,接下来是view ,再到Document,如果消息在上述的对象中没有相应的消息映射,那么消息就返回CWinApp,消息发送到此结束。对于一般的Cwnd 尤其是自定义的派生类是接受不到这种消息的,当然就不会有响应了。

你可能感兴趣的:(CWnd 不能直接响应menus, toolbar buttons, and acceler...)