在RepositionBars函数中有这些代码:for (HWND hWndChild = ::GetTopWindow(m_hWnd); hWndChild != NULL;
hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT))
{
    UINT_PTR nIDC = _AfxGetDlgCtrlID(hWndChild);
    CWnd* pWnd = CWnd::FromHandlePermanent(hWndChild);
    if (nIDC == nIDLeftOver)
hWndLeftOver = hWndChild;
    else if (nIDC >= nIDFirst && nIDC <= nIDLast && pWnd != NULL)
::SendMessage(hWndChild, WM_SIZEPARENT, 0, (LPARAM)&layout);
}书上解释:向每个子窗口发送WM_SIZEPARENT消息,使每个子窗口都能重新安装自己的位置。如果我们把这些代码拿出来,放在一个菜单的操作中测试。Void  CMainFrame::OnTest()
{
   for (HWND hWndChild = ::GetTopWindow(m_hWnd); hWndChild != NULL;
hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT))
  {
     UINT nIDC = _AfxGetDlgCtrlID(hWndChild);
     CString str;
     str.Format("%d",nIDC);
     AfxMessageBox(str);
   }
}得到的消息是:
59648   (AFX_IDW_PANE_FIRST)
59393    (AFX_IDW_STATUS_BAR)
59419    (AFX_IDW_DOCKBAR_TOP)
59422    (AFX_IDW_DOCKBAR_BOTTOM)
59420    (AFX_IDW_DOCKBAR_LEFT)
59421    (AFX_IDW_DOCKBAR_RIGHT)问题出来了,
1、AFX_IDW_DOCKBAR_TOP,AFX_IDW_DOCKBAR_BOTTOM,AFX_IDW_DOCKBAR_LEFT,AFX_IDW_DOCKBAR_RIGHT分别代表什么?
2、为什么没有工具栏的ID号,难道工具栏不在此调整位置和大小,如果不是,什么时候调整工具栏?

解决方案 »

  1.   

    1、参见MSDN中的DcokToolBar这个函数的解释!
      

  2.   

    错了,是CFrameWnd::DockControlBar!不好意思!
      

  3.   

    这是MSDN上的解释:
    void RepositionBars( UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver, UINT nFlag = CWnd::reposDefault, LPRECT lpRectParam = NULL, LPCRECT lpRectClient = NULL, BOOL bStretch = TRUE );ResCalled to reposition and resize control bars in the client area of a window. The nIDFirst and nIDLast parameters define a range of control-bar IDs to be repositioned in the client area. The nIDLeftOver parameter specifies the ID of the child window (normally the view) which is repositioned and resized to fill the rest of the client area not filled by control bars.
      

  4.   

    不明白,怎么联系到CFrameWnd::DockControlBar了。