void CHostWnd::OnLButtonUp(UINT nFlags, CPoint point) { if(!m_isResizing) CWindowsMover::GetInstance()->DoMouseUp(this->m_hWnd, point); if( m_isResizing ) { DrawMoveFrame(m_rcMain); CRect rc; this->GetWindowRect(&rc); m_nDeltaHeight = m_rcMain.Height() - rc.Height(); m_nDeltaWidth = m_rcMain.Width() - rc.Width(); MoveWindow( m_rcMain,true ); ::InvalidateRect(::GetDesktopWindow(), &m_rcMain, true); CWindowsMover::GetInstance()->DoMouseResizingFinished(m_hWnd, nFlags, point, m_iDirection); } if(::GetCapture() == m_hWnd) ::ReleaseCapture(); m_isResizing = FALSE; }
void CHostWnd::OnLButtonDown(UINT nFlags, CPoint point) { ;// PostMessage( WM_NCLBUTTONDOWN, HTCAPTION, (LPARAM)&point ); m_iDirection = 0; if( _needChangeCursor(point)) { m_bChangeCursor = true; SetCapture(); m_isResizing = TRUE; m_ptStartResizing = point; ClientToScreen( &m_ptStartResizing ); GetWindowRect( m_rectStarResizing ); GetWindowRect(&m_rcMain); DrawMoveFrame(m_rcMain); return ; } if(!m_isResizing) CWindowsMover::GetInstance()->DoMouseDown(m_hWnd, point); m_isResizing = FALSE; }
/*--------------------------------------------------------------------------*/ SIGNED PegWindow::Message(const PegMessage &Mesg) { SIGNED Result = 0; PegMessage NewMessage; switch(Mesg.wType) { case PM_POINTER_MOVE: if (muMoveMode) { if (Mesg.Point.x != mMovePoint.x || Mesg.Point.y != mMovePoint.y) { DrawMoveFrame(TRUE); mMovePoint = Mesg.Point; DrawMoveFrame(FALSE); } } else { if (StatusIs(PSF_SIZEABLE) && !mbMaximized) { UCHAR uTemp = BorderContains(Mesg.Point); if (uTemp != mbShowPointer) { mbShowPointer = uTemp; switch(uTemp) { case PMM_MOVELEFT: case PMM_MOVERIGHT: SetPointerType(PPT_HSIZE); break; case PMM_MOVETOP: case PMM_MOVEBOTTOM: SetPointerType(PPT_VSIZE); break; case PMM_MOVEUR: case PMM_MOVELL: SetPointerType(PPT_NESW_SIZE); break; case PMM_MOVEUL: case PMM_MOVELR: SetPointerType(PPT_NWSE_SIZE); break; default: SetPointerType(PPT_NORMAL); break; } } } } break; case PM_SHOW: PegThing::Message(Mesg); #if defined(PEG_KEYBOARD_SUPPORT) && defined(PEG_TAB_KEY_SUPPORT) SetDefaultTabLinks(); #endif if (muScrollMode & WSM_AUTOSCROLL) { CheckAutoScroll(); } break; #if defined(PEG_KEYBOARD_SUPPORT) case PM_GAINED_KEYBOARD: if (!StatusIs(PSF_KEEPS_CHILD_FOCUS)) { MoveFocusToFirstClientChild(); } break; #else case PM_CURRENT: PegThing::Message(Mesg); if (Presentation()->GetCurrentThing() == this && !StatusIs(PSF_KEEPS_CHILD_FOCUS)) { MoveFocusToFirstClientChild(); } break; #endif case PM_ADDICON: AddIcon((PegIcon *) Mesg.pData); break; case PM_BEGIN_MOVE: if (!muMoveMode && StatusIs(PSF_MOVEABLE)) { muMoveMode = (UCHAR) Mesg.iData; mbMoveFrame = FALSE; CapturePointer(); mStartMove = Mesg.Point; mMovePoint = mStartMove; if (muMoveMode == PMM_MOVELR) { SetPointerType(PPT_NWSE_SIZE); mbShowPointer = TRUE; } } break; case PM_POINTER_EXIT: if (mbShowPointer) { SetPointerType(PPT_NORMAL); mbShowPointer = 0; } PegThing::Message(Mesg); break; case PM_LBUTTONDOWN: if (!muMoveMode && StatusIs(PSF_SIZEABLE) && !mbMaximized) { muMoveMode = BorderContains(Mesg.Point); if (muMoveMode) { mbMoveFrame = FALSE; CapturePointer(); mStartMove = Mesg.Point; mMovePoint = mStartMove; } } break; case PM_LBUTTONUP: if (muMoveMode) { DrawMoveFrame(TRUE); SetPointerType(PPT_NORMAL); ReleasePointer(); PegRect OldSize = mReal; if (mStartMove.x == mMovePoint.x && mStartMove.y == mMovePoint.y) { muMoveMode = 0; break; // didn't really move or size anything } PegRect NewSize = mReal; int xShift = mMovePoint.x - mStartMove.x; int yShift = mMovePoint.y - mStartMove.y; switch(muMoveMode) { case PMM_MOVEALL: NewSize.Shift(xShift, yShift); break; case PMM_MOVERIGHT: NewSize.wRight += xShift; break; case PMM_MOVELEFT: NewSize.wLeft += xShift; break; case PMM_MOVETOP: NewSize.wTop += yShift; break; case PMM_MOVEBOTTOM: NewSize.wBottom += yShift; break; case PMM_MOVEUL: NewSize.wLeft += xShift; NewSize.wTop += yShift; break; case PMM_MOVELL: NewSize.wLeft += xShift; NewSize.wBottom += yShift; break; case PMM_MOVEUR: NewSize.wRight += xShift; NewSize.wTop += yShift; break; case PMM_MOVELR: NewSize.wRight += xShift; NewSize.wBottom += yShift; break; } CheckResizeRect(NewSize); NewMessage.wType = PM_SIZE; NewMessage.Rect = NewSize; Message(NewMessage); if (StatusIs(PSF_VISIBLE)) { if (mReal.Contains(OldSize)) { Draw(); } else { Parent()->Draw(); } } muMoveMode = 0; } break; case PM_VSCROLL: MoveClientObjects(0, Mesg.iData - (SIGNED) Mesg.lData); break; case PM_HSCROLL: MoveClientObjects(Mesg.iData - (SIGNED) Mesg.lData, 0); break; case PM_MAXIMIZE: if (StatusIs(PSF_SIZEABLE)) { mbMaximized = TRUE; mRestore = mReal; NewMessage.wType = PM_SIZE; NewMessage.Rect = Parent()->mClient; Message(NewMessage); Draw(); } break; case PM_MINIMIZE: if (StatusIs(PSF_SIZEABLE) && !IsModal()) { NewMessage.wType = PM_ADDICON; PegIcon *pIcon = new PegIcon(this, mpIconMap); pIcon->Id(Id()); NewMessage.pData = pIcon; NewMessage.pTarget = Parent(); MessageQueue()->Push(NewMessage); Parent()->Remove(this); } break; case PM_RESTORE: if (StatusIs(PSF_SIZEABLE)) { if (mbMaximized) { mbMaximized = FALSE; NewMessage.wType = PM_SIZE; NewMessage.Rect = mRestore; Message(NewMessage); Parent()->Draw(); } } break; #ifdef PEG_KEYBOARD_SUPPORT case PM_KEY: if (Parent() == Presentation() && Mesg.iData == PK_F4 && (Mesg.lData & KF_CTRL)) { NewMessage.wType = PM_CLOSE; NewMessage.pTarget = this; MessageQueue()->Push(NewMessage); } else { return PegThing::Message(Mesg); } break; #endif case PM_CLOSE: Destroy(this); return(IDB_CLOSE); case PEG_SIGNAL(IDB_CLOSE, PSF_CLICKED): case PEG_SIGNAL(IDB_OK, PSF_CLICKED): case PEG_SIGNAL(IDB_CANCEL, PSF_CLICKED): case PEG_SIGNAL(IDB_YES, PSF_CLICKED): case PEG_SIGNAL(IDB_NO, PSF_CLICKED): case PEG_SIGNAL(IDB_RETRY, PSF_CLICKED): case PEG_SIGNAL(IDB_ABORT, PSF_CLICKED): case PEG_SIGNAL(IDB_APPLY, PSF_CLICKED): Destroy(this); return(Mesg.iData); default: return (PegThing::Message(Mesg)); } return (Result); }
void CHostWnd::OnMouseMove(UINT nFlags, CPoint point) { if(!m_isResizing) { CWindowsMover::GetInstance()->DoMouseMove(m_hWnd, nFlags, point); } if( !m_isResizing ) { if( !_needChangeCursor( point ) ) { if( m_bChangeCursor ) { HCURSOR m_hCursor = ::LoadCursor(NULL, IDC_ARROW); m_iDirection = 0; ::SetCursor(m_hCursor); m_bChangeCursor = false; } } else { m_bChangeCursor = true; } } if( nFlags & MK_LBUTTON && m_isResizing )//鼠标左键处于点击状态下 { CPoint tmpPT = point; ClientToScreen(&tmpPT); //先获得当前Pt 和 开始点击 的位置的 差值 CPoint diff; diff.x = tmpPT.x - m_ptStartResizing.x; diff.y = tmpPT.y - m_ptStartResizing.y; CRect newRect; if( m_iDirection & DIRECTION_LEFT ) { newRect.left = m_rectStarResizing.left + diff.x; newRect.right = m_rectStarResizing.right; newRect.bottom = m_rectStarResizing.bottom; newRect.top = m_rectStarResizing.top; if( m_iDirection & DIRECTION_TOP ) { newRect.top += diff.y; } else if( m_iDirection & DIRECTION_BOTTOM ) { newRect.bottom += diff.y; } } else if( m_iDirection & DIRECTION_RIGHT ) { newRect.left = m_rectStarResizing.left; newRect.right = m_rectStarResizing.right + diff.x; newRect.bottom = m_rectStarResizing.bottom; newRect.top = m_rectStarResizing.top; if( m_iDirection & DIRECTION_TOP ) { newRect.top += diff.y; } else if( m_iDirection & DIRECTION_BOTTOM ) { newRect.bottom += diff.y; } } else if( m_iDirection & DIRECTION_TOP ) { newRect.left = m_rectStarResizing.left; newRect.right = m_rectStarResizing.right; newRect.bottom = m_rectStarResizing.bottom; newRect.top = m_rectStarResizing.top + diff.y; if( m_iDirection & DIRECTION_LEFT ) { newRect.left += diff.x; } else if( m_iDirection & DIRECTION_RIGHT ) { newRect.right += diff.x; } } else if( m_iDirection & DIRECTION_BOTTOM ) { newRect.left = m_rectStarResizing.left; newRect.right = m_rectStarResizing.right; newRect.bottom = m_rectStarResizing.bottom + diff.y; newRect.top = m_rectStarResizing.top; if( m_iDirection & DIRECTION_LEFT ) { newRect.left += diff.x; } else if( m_iDirection & DIRECTION_RIGHT ) { newRect.right += diff.x; } } else { __super::OnMouseMove( nFlags,point ); return; } if(newRect.Width() < m_nMinCx) { if(m_iDirection & DIRECTION_RIGHT) newRect.right = newRect.left + m_nMinCx; else newRect.left = newRect.right - m_nMinCx; } if(newRect.Height() < m_nMinCy) { if(m_iDirection & DIRECTION_BOTTOM) newRect.bottom = newRect.top + m_nMinCy; else newRect.top = newRect.bottom - m_nMinCy; } DrawMoveFrame(m_rcMain); m_rcMain = newRect; DrawMoveFrame(m_rcMain); } __super::OnMouseMove( nFlags,point ); }