BOOL CControlBar::DestroyWindow() { if (m_hWnd != NULL && IsFloating()) return GetDockingFrame()->DestroyWindow(); else return CWnd::DestroyWindow(); }
void CDockBar::RemoveControlBar(CControlBar* pBar, int nPosExclude) { ASSERT_VALID(this); ASSERT(pBar != NULL); int nPos = FindBar(pBar, nPosExclude); ASSERT(nPos > 0); m_arrBars.RemoveAt(nPos); // remove section indicator (NULL) if nothing else in section if (m_arrBars[nPos-1] == NULL && m_arrBars[nPos] == NULL) m_arrBars.RemoveAt(nPos); // get parent frame for recalc layout/frame destroy CFrameWnd* pFrameWnd = GetDockingFrame(); if (m_bFloating && GetDockedVisibleCount() == 0) { if (m_arrBars.GetSize() == 1) pFrameWnd->DestroyWindow(); else pFrameWnd->ShowWindow(SW_HIDE); } else pFrameWnd->DelayRecalcLayout(); }
void CCJSizeDockBar::OnNcLButtonDown(UINT nHitTest, CPoint point) { if( m_bOkToDrag ) { UINT nID = ((UINT)(WORD)::GetDlgCtrlID(m_hWnd)); CFrameWnd *pFrame=GetDockingFrame(); GetWindowRect(m_rcTrack); if (nID == AFX_IDW_SIZEBAR_LEFT) m_rcTrack.left = m_rcTrack.right-m_iTrackBorderSize; else if (nID == AFX_IDW_SIZEBAR_TOP) m_rcTrack.top = m_rcTrack.bottom-m_iTrackBorderSize; else if (nID == AFX_IDW_SIZEBAR_RIGHT) m_rcTrack.right = m_rcTrack.left+m_iTrackBorderSize; else if (nID == AFX_IDW_SIZEBAR_BOTTOM) m_rcTrack.bottom = m_rcTrack.top+m_iTrackBorderSize; pFrame->ScreenToClient(&m_rcTrack); pFrame->ScreenToClient(&point); m_ptStartDrag = point; m_ptCurDrag = point; SetCapture(); m_bDragging = TRUE; OnInvertTracker(m_rcTrack); } CDockBar::OnNcLButtonDown(nHitTest, point); }
void CGuiControlBar::OnNcLButtonUp(UINT nHitTest, CPoint point) { // TODO: Add your message handler code here and/or call default CRect rc; //------------------ para el boton CRect rcT=m_rcCloseBtn; ClientToScreen(rcT); point.y+=23; point.x+=5; if (rcT.PtInRect(point)) { if (m_stateBtn ==PRESS) { m_stateBtn=NORMAL; KillTimer(1); GetDockingFrame()->ShowControlBar(this, FALSE, FALSE); } //SendMessage(WM_NCPAINT); return; } //-------------------para el boton }
void CCJSizeDockBar::OnInvertTracker(const CRect& rect) { ASSERT_VALID(this); ASSERT(!rect.IsRectEmpty()); CDC* pDC = GetDockingFrame()->GetDC(); CBrush* pBrush = CDC::GetHalftoneBrush(); HBRUSH hOldBrush = NULL; if (pBrush != NULL) hOldBrush = (HBRUSH)SelectObject(pDC->m_hDC, pBrush->m_hObject); pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATINVERT); if (hOldBrush != NULL) SelectObject(pDC->m_hDC, hOldBrush); GetDockingFrame()->ReleaseDC(pDC); }
BOOL CLeftPanelDlgBar::OnEraseBkgnd(CDC* pDC) { // Use the same background color as that of the dialog Mark (pDC, m_rcCurMark, true); if (GetDockingFrame () == NULL) return TRUE; return CDialogBar::OnEraseBkgnd(pDC); }
void CCJSizeDockBar::OnMouseMove(UINT nFlags, CPoint point) { if( m_bDragging ) { CRect rectWin; GetWindowRect(&rectWin); CRect rectAvail; GetAvailableRect(rectAvail); CFrameWnd *pFrame=GetDockingFrame(); ClientToScreen(&point); pFrame->ScreenToClient(&point); UINT nID = ((UINT)(WORD)::GetDlgCtrlID(m_hWnd)); if (nID == AFX_IDW_SIZEBAR_LEFT) { point.x = point.x>rectAvail.right ? rectAvail.right:point.x; point.x = point.x<m_iTrackBorderSize ? m_iTrackBorderSize:point.x; } else if (nID == AFX_IDW_SIZEBAR_TOP) { point.y = point.y>rectAvail.bottom ? rectAvail.bottom:point.y; point.y = point.y<m_iTrackBorderSize ? m_iTrackBorderSize:point.y; } else if (nID == AFX_IDW_SIZEBAR_RIGHT) { point.x = point.x<rectAvail.left ? rectAvail.left:point.x; point.x = point.x>rectAvail.right+m_iActualSize-m_iTrackBorderSize ? rectAvail.right-m_iTrackBorderSize+m_iActualSize:point.x; } else if (nID == AFX_IDW_SIZEBAR_BOTTOM) { point.y = point.y<rectAvail.top ? rectAvail.top:point.y; point.y = point.y>rectAvail.bottom+m_iActualSize-m_iTrackBorderSize ? rectAvail.bottom-m_iTrackBorderSize+m_iActualSize:point.y; } int deltaX = point.x-m_ptCurDrag.x; int deltaY = point.y-m_ptCurDrag.y; m_ptCurDrag = point; if (nID == AFX_IDW_SIZEBAR_LEFT || nID == AFX_IDW_SIZEBAR_RIGHT && deltaX) { OnInvertTracker(m_rcTrack); m_rcTrack.left+=deltaX; m_rcTrack.right+=deltaX; OnInvertTracker(m_rcTrack); } else if( nID == AFX_IDW_SIZEBAR_TOP || nID == AFX_IDW_SIZEBAR_BOTTOM && deltaY) { OnInvertTracker(m_rcTrack); m_rcTrack.top+=deltaY; m_rcTrack.bottom+=deltaY; OnInvertTracker(m_rcTrack); } } CDockBar::OnMouseMove(nFlags, point); }
void CCJSizeDockBar::OnLButtonUp(UINT nFlags, CPoint point) { if( m_bDragging ) { CRect rectWin; CRect rectAvail; GetWindowRect(&rectWin); ReleaseCapture(); m_bDragging = FALSE; OnInvertTracker(m_rcTrack); GetAvailableRect(rectAvail); UINT nID = ((UINT)(WORD)::GetDlgCtrlID(m_hWnd)); if (nID == AFX_IDW_SIZEBAR_LEFT ) { int maxWidth = rectAvail.Width()-m_iSafeSpace; int newWidth = m_rcTrack.left-m_ptStartDrag.x; m_iActualSize = newWidth>maxWidth ? maxWidth: newWidth; m_iActualSize += rectWin.Width(); } else if (nID == AFX_IDW_SIZEBAR_TOP) { int maxHeight = rectAvail.Height()-m_iSafeSpace; int newHeight = m_rcTrack.top-m_ptStartDrag.y; m_iActualSize = newHeight>maxHeight ? maxHeight : newHeight; m_iActualSize += rectWin.Height(); } else if (nID == AFX_IDW_SIZEBAR_RIGHT) { int maxWidth = rectAvail.Width()-m_iSafeSpace; int newWidth = m_ptStartDrag.x-m_rcTrack.left; m_iActualSize = newWidth>maxWidth ? maxWidth: newWidth; m_iActualSize += rectWin.Width(); } else if (nID == AFX_IDW_SIZEBAR_BOTTOM) { int maxHeight = rectAvail.Height()-m_iSafeSpace; int newHeight = m_ptStartDrag.y-m_rcTrack.top; m_iActualSize = newHeight>maxHeight ? maxHeight : newHeight; m_iActualSize += rectWin.Height(); } if(m_iActualSize<m_iTrackBorderSize ) m_iActualSize = m_iTrackBorderSize; GetDockingFrame()->RecalcLayout(); RecalcAllExcept(NULL); } CDockBar::OnLButtonUp(nFlags, point); }
void CGuiOfficeBar::OnNcLButtonUp(UINT nHitTest, CPoint point) { // TODO: Add your message handler code here and/or call default CRect rcT; point.y+=23; point.x+=5; if (m_stateBtnBack!=NORMAL) rcT=m_ArrButtons[0].rcArea; else if(m_stateBtnFor!=NORMAL) rcT=m_ArrButtons[1].rcArea; else if(m_stateBtnMenu!=NORMAL) rcT=m_ArrButtons[2].rcArea; else if(m_stateBtnClose!=NORMAL) rcT=m_ArrButtons[3].rcArea; ClientToScreen(rcT); if (rcT.PtInRect(point)) { if (m_StateBtn ==PRESS) { if(m_stateBtnClose!=NORMAL) GetDockingFrame()->ShowControlBar(this, FALSE, FALSE); else { SendMessage (WM_COMMAND,m_nHits); AfxGetMainWnd()->SendMessage(WM_COMMAND,m_nHits); } m_StateBtn=NORMAL; m_stateBtnBack=NORMAL; m_stateBtnClose=NORMAL; m_stateBtnFor=NORMAL; m_stateBtnMenu=NORMAL; m_nHits=-1; KillTimer(1); } //SendMessage(WM_NCPAINT); return; } CGuiControlBar::OnNcLButtonUp(nHitTest, point); }
void CCoolDialogBar::OnNcLButtonDown(UINT nHitTest, CPoint point) { if (m_bTracking) return; if((nHitTest == HTSYSMENU) && !IsFloating()) GetDockingFrame()->ShowControlBar(this, FALSE, FALSE); else if ((nHitTest == HTMINBUTTON) && !IsFloating()) m_pDockContext->ToggleDocking(); else if ((nHitTest == HTCAPTION) && !IsFloating() && (m_pDockBar != NULL)) { // start the drag ASSERT(m_pDockContext != NULL); m_pDockContext->StartDrag(point); } else if ((nHitTest == HTSIZE) && !IsFloating()) StartTracking(); else CControlBar::OnNcLButtonDown(nHitTest, point); }
CSize CCJControlBar::CalcDynamicLayout(int nLength, DWORD dwMode) { if (dwMode & (LM_HORZDOCK | LM_VERTDOCK)) { if (nLength == -1) GetDockingFrame()->DelayRecalcLayout(); return CControlBar::CalcDynamicLayout(nLength,dwMode); } if (dwMode & LM_MRUWIDTH) return m_sizeFloat; if (dwMode & LM_COMMIT) { m_sizeFloat.cx = nLength; return m_sizeFloat; } if (dwMode & LM_LENGTHY) return CSize(m_sizeFloat.cx, m_sizeFloat.cy = max(m_sizeMin.cy, nLength)); else return CSize(max(m_sizeMin.cx, nLength), m_sizeFloat.cy); }
void CDynamicHelp::OnCloseWnd() { if (CFrameWnd* frame_wnd= GetDockingFrame()) frame_wnd->ShowControlBar(this, false, TRUE); }
void CCJControlBar::OnButtonClose() { GetDockingFrame()->ShowControlBar(this, FALSE, FALSE); }
void CDialogBarEx::OnMouseMove(UINT nFlags, CPoint point) { // // 如果鼠标为在关闭按钮区则改变m_IsCursorInWnd并且启动 // 监视鼠标是否离开窗口的事件 // if(m_IsCursorInWnd==false) { TRACKMOUSEEVENT TraceStruct; TraceStruct.cbSize=sizeof(TRACKMOUSEEVENT); TraceStruct.dwFlags=TME_LEAVE; TraceStruct.dwHoverTime=HOVER_DEFAULT; TraceStruct.hwndTrack=this->GetSafeHwnd(); TrackMouseEvent(&TraceStruct); m_IsCursorInWnd=true; } //停靠的并前没有被扑获 if(!IsFloating() && !m_IsCapture) { CRect TopBorderRect,BottomBorderRect; CRect LeftBorderRect,RightBorderRect; // HCURSOR hCursor; CWnd::GetClientRect(&TopBorderRect); CWnd::GetClientRect(&BottomBorderRect); CWnd::GetClientRect(&LeftBorderRect); CWnd::GetClientRect(&RightBorderRect); TopBorderRect.top=TopBorderRect.bottom-8; BottomBorderRect.bottom=8; LeftBorderRect.left=LeftBorderRect.right-8; RightBorderRect.right=8; //如果停靠在下边并且在可改变大小的区域内 if(BottomBorderRect.PtInRect(point) && this->GetDockingSide()==4) { this->m_DragSizeArea=1; // hCursor=AfxGetApp()->LoadCursor(IDC_SPLITV); // ::SetCursor(hCursor); // ::DeleteObject(hCursor); ::SetCursor(m_hCursorV); } //如果停靠在上边并且在可改变大小的区域内 else if(TopBorderRect.PtInRect(point) && this->GetDockingSide()==3) { this->m_DragSizeArea=2; // hCursor=AfxGetApp()->LoadCursor(IDC_SPLITV); // ::SetCursor(hCursor); // ::DeleteObject(hCursor); ::SetCursor(m_hCursorV); } //如果停靠在左边并且在可改变大小的区域内 else if(LeftBorderRect.PtInRect(point) && this->GetDockingSide()==1) { this->m_DragSizeArea=4; // hCursor=AfxGetApp()->LoadCursor(IDC_SPLITH); // ::SetCursor(hCursor); // ::DeleteObject(hCursor); ::SetCursor(m_hCursorH); } //如果停靠在右边并且在可改变大小的区域内 else if(RightBorderRect.PtInRect(point) && this->GetDockingSide()==2) { this->m_DragSizeArea=3; // hCursor=AfxGetApp()->LoadCursor(IDC_SPLITH); // ::SetCursor(hCursor); // ::DeleteObject(hCursor); ::SetCursor(m_hCursorH); } else { this->m_DragSizeArea=0; } } ///////////////////////////////////////////////// // // 在标题拦类点击了左键 // if(m_IsCapture && this->m_DragSizeArea==0) { if(abs(point.y-m_CapturePt.y)>35 || abs(point.x-m_CapturePt.x)>35) { CString strText; this->GetWindowText(strText); this->ClientToScreen(&point); this->m_pContainWnd->SetSubDialogBar(this,point); this->m_pContainWnd->SetWindowText(strText); } } if(m_IsCapture && this->m_DragSizeArea!=0) { CPoint pt1,pt2; //可以向上拖动从而改变大小 if(this->m_DragSizeArea==1) { this->m_InitSize.cy+=m_CapturePt.y-point.y; ::SetCursor(m_hCursorV); } //可以向下拖动从而改变大小 else if(this->m_DragSizeArea==2) { pt1=m_CapturePt; pt2=point; this->ClientToScreen(&pt1); this->ClientToScreen(&pt2); this->m_InitSize.cy+=pt2.y-pt1.y; m_CapturePt=point; ::SetCursor(m_hCursorV); } //可以向右拖动从而改变大小 else if(this->m_DragSizeArea==4) { pt1=m_CapturePt; pt2=point; this->ClientToScreen(&pt1); this->ClientToScreen(&pt2); this->m_InitSize.cx+=pt2.x-pt1.x; m_CapturePt=point; ::SetCursor(m_hCursorH); } //可以向左拖动从而改变大小 else if(this->m_DragSizeArea==3) { this->m_InitSize.cx+=m_CapturePt.x-point.x; ::SetCursor(m_hCursorH); } GetDockingFrame()->RecalcLayout(); this->Invalidate(); } // // 判断是否在关闭按钮内,如果状态改变重绘窗口 // if(this->m_CloseButtonRect.PtInRect(point)) { if(this->m_IsInCloseButton==false) { this->Invalidate(); } HCURSOR hCursor2; this->m_IsInCloseButton=true; hCursor2 = LoadCursor(NULL, IDC_ARROW); ::SetCursor(hCursor2); ::DeleteObject(hCursor2); } else { if(this->m_IsInCloseButton==true) { this->Invalidate(); } this->m_IsInCloseButton=false; } }
CSize CToolbarWnd::CalcDynamicLayout(int nLength, DWORD dwMode) { CFrameWnd* pFrm = GetDockingFrame(); // This function is typically called with // CSize sizeHorz = m_pBar->CalcDynamicLayout(0, LM_HORZ | LM_HORZDOCK); // CSize sizeVert = m_pBar->CalcDynamicLayout(0, LM_VERTDOCK); // CSize sizeFloat = m_pBar->CalcDynamicLayout(0, LM_HORZ | LM_MRUWIDTH); CRect rcFrmClnt; pFrm->GetClientRect(&rcFrmClnt); CRect rcInside = rcFrmClnt; CalcInsideRect(rcInside, dwMode & LM_HORZDOCK); CRect rcBorders; rcBorders.left = rcInside.left - rcFrmClnt.left; rcBorders.top = rcInside.top - rcFrmClnt.top; rcBorders.bottom = rcFrmClnt.bottom - rcInside.bottom; rcBorders.right = rcFrmClnt.right - rcInside.right; if (dwMode & (LM_HORZDOCK | LM_VERTDOCK)) { if (dwMode & LM_VERTDOCK) { CSize szFloat; szFloat.cx = MIN_VERT_WIDTH; szFloat.cy = rcFrmClnt.Height() + GetSystemMetrics(SM_CYEDGE) * 2; m_szFloat = szFloat; return szFloat; } else if (dwMode & LM_HORZDOCK) { CSize szFloat; szFloat.cx = rcFrmClnt.Width() + GetSystemMetrics(SM_CXEDGE) * 2; szFloat.cy = m_sizeDefault.cy + rcBorders.top + rcBorders.bottom; m_szFloat = szFloat; return szFloat; } return CDialogBar::CalcDynamicLayout(nLength, dwMode); } if (dwMode & LM_MRUWIDTH) { return m_szMRU; } if (dwMode & LM_COMMIT) { m_szMRU = m_szFloat; return m_szFloat; } CSize szFloat; if ((dwMode & LM_LENGTHY) == 0) { szFloat.cx = nLength; if (nLength < m_sizeDefault.cx + rcBorders.left + rcBorders.right) { szFloat.cx = MIN_VERT_WIDTH; szFloat.cy = MIN_HORZ_WIDTH; } else { szFloat.cy = m_sizeDefault.cy + rcBorders.top + rcBorders.bottom; } } else { szFloat.cy = nLength; if (nLength < MIN_HORZ_WIDTH) { szFloat.cx = m_sizeDefault.cx + rcBorders.left + rcBorders.right; szFloat.cy = m_sizeDefault.cy + rcBorders.top + rcBorders.bottom; } else { szFloat.cx = MIN_VERT_WIDTH; } } m_szFloat = szFloat; return szFloat; }
void CDockBar::DockControlBar(CControlBar* pBar, LPCRECT lpRect) { ASSERT_VALID(this); ASSERT_VALID(pBar); ASSERT(pBar->IsKindOf(RUNTIME_CLASS(CControlBar))); // set CBRS_FLOAT_MULTI style if docking bar has it if (m_bFloating && (pBar->m_dwDockStyle & CBRS_FLOAT_MULTI)) m_dwStyle |= CBRS_FLOAT_MULTI; CRect rectBar; pBar->GetWindowRect(&rectBar); if (pBar->m_pDockBar == this && (lpRect == NULL || rectBar == *lpRect)) { // already docked and no change in position return; } if (!(m_dwStyle & CBRS_FLOAT_MULTI)) { CString strTitle; pBar->GetWindowText(strTitle); AfxSetWindowText(m_hWnd, strTitle); } // align correctly and turn on all borders pBar->m_dwStyle &= ~(CBRS_ALIGN_ANY); pBar->m_dwStyle |= (m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY; int nPos = -1; if (lpRect != NULL) { // insert into appropriate row CRect rect(lpRect); ScreenToClient(&rect); CPoint ptMid(rect.left + rect.Width()/2, rect.top + rect.Height()/2); nPos = Insert(pBar, rect, ptMid); // position at requested position pBar->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS); } else { // always add on current row, then create new one m_arrBars.Add(pBar); m_arrBars.Add(NULL); // align off the edge initially pBar->SetWindowPos(NULL, -afxData.cxBorder2, -afxData.cyBorder2, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); } // attach it to the docking site if (pBar->GetParent() != this) pBar->SetParent(this); if (pBar->m_pDockBar == this) pBar->m_pDockBar->RemoveControlBar(pBar, nPos); else if (pBar->m_pDockBar != NULL) pBar->m_pDockBar->RemoveControlBar(pBar); pBar->m_pDockBar = this; // get parent frame for recalc layout CFrameWnd* pFrameWnd = GetDockingFrame(); pFrameWnd->DelayRecalcLayout(); }
void CCJSizeDockBar::GetAvailableRect(CRect &rect) { GetDockingFrame()->GetClientRect(&rect); GetDockingFrame()->RepositionBars(0xffff, 0xffff, AFX_IDW_PANE_FIRST,reposQuery, &rect, &rect, TRUE); }