当前位置: 代码迷 >> 多核软件开发 >> CStatusBarEx继承CStatusBar后,重载OnMouseMove等鼠标事件,目的是模拟右下角的Gripper改变窗口大小效果,但改变不了。贴代码。该怎么解决
  详细解决方案

CStatusBarEx继承CStatusBar后,重载OnMouseMove等鼠标事件,目的是模拟右下角的Gripper改变窗口大小效果,但改变不了。贴代码。该怎么解决

热度:2080   发布时间:2013-02-26 00:00:00.0
CStatusBarEx继承CStatusBar后,重载OnMouseMove等鼠标事件,目的是模拟右下角的Gripper改变窗口大小效果,但改变不了。贴代码。
代码如下。怎样改才能像右下角的Gripper改变窗口大小效果?

void CStatusBarEx::OnMouseMove(UINT nFlags, CPoint point) 
{
CRect rect1;
GetClientRect(&rect1);

if(point.x >= rect1.right - 40 && point.x <= rect1.right - 20 && point.y >= rect1.top && point.y <= rect1.bottom)
{
m_bMouseEntered = TRUE;

SetCursor(m_hCursor);


if(m_bMousePressed)
{
CWnd* pWnd = AfxGetApp()->GetMainWnd();
if(pWnd && pWnd->GetSafeHwnd())
{
CRect rect1;
pWnd->GetWindowRect(&rect1);

rect1.right += (point.x - m_point.x);
rect1.bottom += (point.y - m_point.y);

pWnd->MoveWindow(&rect1);
pWnd->UpdateWindow();

m_point = point;

}
}
}

CStatusBar::OnMouseMove(nFlags, point);
}

void CStatusBarEx::OnLButtonDown(UINT nFlags, CPoint point) 
{
m_bMousePressed = TRUE;

if(m_bMouseEntered)
{
SetCursor(m_hCursor);
m_point = point;
}

CStatusBar::OnLButtonDown(nFlags, point);
}

void CStatusBarEx::OnLButtonUp(UINT nFlags, CPoint point) 
{
if(m_bMouseEntered)
{
SetCursor(m_hCursor);
m_point = point;
}

CStatusBar::OnLButtonUp(nFlags, point);
}


------解决方案--------------------------------------------------------
http://blog.csdn.net/visualeleven/article/details/6223577