移动/缩放窗口

 void CDlgLogin::OnLButtonDown(UINT nFlags, CPoint point)
{
 m_btnZoom.GetWindowRect(&m_rect);
    ScreenToClient(&m_rect);

 if(m_rect.PtInRect(point))
 {
  m_bZoomWindow = TRUE;
 }
 else
 {
     m_bMoveWindow = TRUE;
 }

 m_Pos = point;
 SetCapture();
 
 CDialog::OnLButtonDown(nFlags, point);
}

void CDlgLogin::OnLButtonUp(UINT nFlags, CPoint point)
{
 if (m_bMoveWindow)
 m_bMoveWindow = FALSE;

 m_bZoomWindow = FALSE;

 ReleaseCapture();

 CDialog::OnLButtonUp(nFlags, point);
}


void CDlgLogin::OnMouseMove(UINT nFlags, CPoint point)
{
 //缩放窗口
 if(m_bZoomWindow)
 {
  CRect crWindow;
  GetWindowRect(&crWindow);

  ClientToScreen(&point);

  crWindow.SetRect(crWindow.left,crWindow.top,point.x,point.y);
  
  if( theWindowManager->m_bMainStyle == FALSE )
   ::MoveWindow(theWindowManager->GetMainWnd(),crWindow.left,crWindow.top,crWindow.Width() ,crWindow.Height() , TRUE);

  Invalidate();
 }

 
 //移动窗口
 if (m_bMoveWindow && !m_bZoomWindow)
 {
  CPoint newPoint;
  newPoint = point;
  ClientToScreen(&newPoint);
  //
  newPoint.x = newPoint.x - m_Pos.x;
  newPoint.y = newPoint.y - m_Pos.y;

  CRect crWindow;
  GetWindowRect(&crWindow);
        crWindow.OffsetRect(point);
  crWindow.SetRect(newPoint.x, newPoint.y, crWindow.Width() + newPoint.x, crWindow.Height() + newPoint.y);

  if( theWindowManager->m_bMainStyle == FALSE )
   ::MoveWindow(theWindowManager->GetMainWnd(),crWindow.left,crWindow.top,crWindow.Width(),crWindow.Height(), TRUE);
  
 }


 CRect rect;
 GetClientRect(&rect);
 ClientToScreen(&rect);
 rect.top = rect.bottom - 10;
 rect.left = rect.right - 10;

 CPoint pt;
 GetCursorPos(&pt);

 if(rect.PtInRect(pt))
 {
  SetCursor(LoadCursor(NULL,MAKEINTRESOURCE(IDC_SIZENWSE)));
  }

 CDialog::OnMouseMove(nFlags, point);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值