SendMessage的两个小问题
我用MFC的向导建立了一个基于对话框的程序,在对话框的OnInitDialog中AfxBeginThread(CommuProc, 0)开启一个线程,线程的代码如下:
UINT CommuProc(LPVOID pParam){ MSG msg; while (1) { if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == CM_TEST1) { ::SendMessage(hDlgWnd, CM_T2D_1, 0, 0);//hDlgWnd是对话框的窗口句柄 } } } return 0;}To process messages for the modal dialog box, the system starts its own message loop, taking temporary control of the message queue for the entire application. When the system retrieves a message that is not explicitly for the dialog box, it dispatches the message to the appropriate window. If it retrieves a WM_QUIT message, it posts the message back to the application message queue so that the application's main message loop can eventually retrieve the message.