请问MoveWindow在这里为什么不起作用?????
我写了个控件
想让它可以在程序里用鼠标拖动
然后我在网上抄了一段代码,问题是解决了
但我有一句话就看不懂了
void CAmodaoshiCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
m_IsMove=true;
SetCapture();//捕获鼠标
xx=point.x;//得到鼠标(相对于控件左上角)的坐标
yy=point.y;
GetClientRect(&rect);//保存拖动前的控件位置
::ClientToScreen(m_hWnd,&rect.TopLeft());
OldPoint=rect.TopLeft();
MoveWindow(0,0,100,120);//得到相对量////////这一句是什么意思??为什么控件不动?
GetClientRect(&rect);
::ClientToScreen(m_hWnd,&rect.TopLeft());
COleControl::OnLButtonDown(nFlags, point);
}
void CAmodaoshiCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
CPoint MyPoint=point;
if(m_IsMove)
{
ClientToScreen(&MyPoint);
MoveWindow(MyPoint.x-xx-rect.left,MyPoint.y-yy-rect.top,50,22);
}
COleControl::OnMouseMove(nFlags, point);
}
void CAmodaoshiCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
if(m_IsMove)
{
ReleaseCapture();
m_IsMove=false;
}
ReleaseCapture();
COleControl::OnLButtonUp(nFlags, point);
}
大家请看,在OnLButtonDown里,有一句MoveWindow,但实际上好像没有移动控件的功能把
为什么啊??????