GetMessage(&m_msg, NULL, 0, 0);
TranslateMessage(&m_msg);
DispatchMessage(&m_msg);能把消息发送到窗体,窗体处理消息。但在进行消息循环之前的的窗体消息是从哪里来的?例如,登录窗口。CeLogin Login();
Login.L.DoModal();GetMessage(&m_msg, NULL, 0, 0);
TranslateMessage(&m_msg);
DispatchMessage(&m_msg);对此一直不解,请各位大大指教!!!!!

解决方案 »

  1.   

    创建窗口的时候,会建立相关窗口的消息循环队列;对于没有窗口的线程,也可以通过 PeekMessage 创建消息队列
      

  2.   

    模态对话框有自己的消息循环,可以Debug,F11进入DoModal()函数内部中看看
      

  3.   

    INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow(), LPARAM dwInitParam = NULL)
    {
    BOOL result; ATLASSUME(m_hWnd == NULL); // Allocate the thunk structure here, where we can fail
    // gracefully. result = m_thunk.Init(NULL,NULL);
    if (result == FALSE) 
    {
    SetLastError(ERROR_OUTOFMEMORY);
    return -1;
    } _AtlWinModule.AddCreateWndData(&m_thunk.cd, (CDialogImplBaseT< TBase >*)this);
    #ifdef _DEBUG
    m_bModal = true;
    #endif //_DEBUG
    return ::DialogBoxParam(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(static_cast<T*>(this)->IDD),
    hWndParent, T::StartDialogProc, dwInitParam);
    }DoModal 里没有找到
    GetMessage(&m_msg, NULL, 0, 0);
    TranslateMessage(&m_msg);
    DispatchMessage(&m_msg);
    对话框的T::StartDialogProc消息处理里的消息是哪里来的?