代码改变世界

MFC中的问题记录 2012-2-20

2012-02-20 16:28  Clingingboy  阅读(475)  评论(0编辑  收藏  举报

 

  1. 模态窗体的实现

    bool CWindowWnd::ShowModal()
    {
       ASSERT(::IsWindow(m_hWnd));
       
       HWND hWndParent = GetWindowOwner(m_hWnd);
       ::ShowWindow(m_hWnd, SW_SHOWNORMAL);
       ::EnableWindow(hWndParent, FALSE);
       MSG msg = { 0 };
       while( ::IsWindow(m_hWnd) && ::GetMessage(&msg, NULL, 0, 0) ) {
          if( msg.message == WM_CLOSE ) {
             ::EnableWindow(hWndParent, TRUE);
             ::SetFocus(hWndParent);
          }
          if( !CPaintManagerUI::TranslateMessage(&msg) ) {
             ::TranslateMessage(&msg);
             ::DispatchMessage(&msg);
          }
          if( msg.message == WM_QUIT ) break;
       }
       ::EnableWindow(hWndParent, TRUE);
       ::SetFocus(hWndParent);
       if( msg.message == WM_QUIT ) ::PostQuitMessage(msg.wParam);
       return true;
    }
    


  2. 谈谈父窗口和所有者窗口
  3. WM_NCCREATE
  4. GWLP_USERDATA
    Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.
  5. 《C++设计新思维》读书笔记