void CLogo::SetPosition() { if(!::IsWindow(m_hWnd)) return; CDockBar* pTopDockBar = GetParentDockBar(); if(!pTopDockBar) return; CRect TopDockBarRect; pTopDockBar->GetClientRect(TopDockBarRect); CRect LogoRect; GetWindowRect(LogoRect); pTopDockBar->ScreenToClient(LogoRect); int nLeft = TopDockBarRect.right-LogoRect.Width()-::GetSystemMetrics(SM_CXEDGE); int nTop = TopDockBarRect.top; if(nLeft != LogoRect.left || nTop != LogoRect.top) SetWindowPos(NULL, nLeft, nTop, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE); CRect UnionToolbarRect; for(int nI=0;nI<pTopDockBar->m_arrBars.GetSize();nI++) { CWnd* pWnd = static_cast<CWnd*>(pTopDockBar->m_arrBars[nI]); if(!pWnd || !AfxIsValidAddress(pWnd,sizeof(CWnd)) || !::IsWindow(*pWnd)) continue; CRect ToolBarRect; pWnd->GetWindowRect(&ToolBarRect); UnionToolbarRect.UnionRect(UnionToolbarRect,ToolBarRect); } GetWindowRect(LogoRect); UnionToolbarRect.IntersectRect(UnionToolbarRect,LogoRect); if(UnionToolbarRect.IsRectEmpty()) { if(!IsWindowVisible()) ShowWindow(SW_SHOW); } else { if(IsWindowVisible()) ShowWindow(SW_HIDE); } }
void CGuiDockContext::EndDrag() { CancelLoop(); if (m_dwOverDockStyle != 0) { CDockBar* pDockBar = GetDockBar(m_dwOverDockStyle); ASSERT(pDockBar != NULL); CRect rect = (m_dwOverDockStyle & CBRS_ORIENT_VERT) ? m_rectDragVert : m_rectDragHorz; UINT uID = _AfxGetDlgCtrlID(pDockBar->m_hWnd); if (uID >= AFX_IDW_DOCKBAR_TOP && uID <= AFX_IDW_DOCKBAR_BOTTOM) { m_uMRUDockID = uID; m_rectMRUDockPos = rect; pDockBar->ScreenToClient(&m_rectMRUDockPos); } // dock it at the specified position, RecalcLayout will snap m_pDockSite->DockControlBar(m_pBar, pDockBar, &rect); m_pDockSite->RecalcLayout(); } else if ((m_dwStyle & CBRS_SIZE_DYNAMIC) || (HORZF(m_dwStyle) && !m_bFlip) || (VERTF(m_dwStyle) && m_bFlip)) { m_dwMRUFloatStyle = CBRS_ALIGN_TOP | (m_dwDockStyle & CBRS_FLOAT_MULTI); m_ptMRUFloatPos = m_rectFrameDragHorz.TopLeft(); m_pDockSite->FloatControlBar(m_pBar, m_ptMRUFloatPos, m_dwMRUFloatStyle); } else // vertical float { m_dwMRUFloatStyle = CBRS_ALIGN_LEFT | (m_dwDockStyle & CBRS_FLOAT_MULTI); m_ptMRUFloatPos = m_rectFrameDragVert.TopLeft(); m_pDockSite->FloatControlBar(m_pBar, m_ptMRUFloatPos, m_dwMRUFloatStyle); } }