高分求救矩形框的问题 如果想用鼠标拉出来一个矩形框 并且该矩形框画好后能够用鼠标随意改变其大小和移动它到任意位置请问如何实现阿?最好能给我原码 万分感谢回答后立刻节帖给分 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 void CPictureActiveCtrl::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください StartPoint=point; mousedown=TRUE; CClientDC ddc(this);// OnDraw(&ddc,&Clientrect,NULL); OnResetState(); if(DectrionMove) { bPointmouse=TRUE; oldselRect=CRect(0,0,0,0); ddc.LPtoDP(oldselRect); DrawRect.NormalizeRect(); oldselRect.NormalizeRect(); ddc.DrawDragRect(DrawRect,sz,oldselRect,sz ,&Drawbrush,NULL); oldselRect=DrawRect; bDrawed=TRUE; } else { bDrawed=FALSE; bPointmouse=FALSE; DectrionMove=FALSE; } COleControl::OnLButtonDown(nFlags, point);}void CPictureActiveCtrl::OnLButtonUp(UINT nFlags, CPoint point) { mousedown=FALSE; bPointmouse=FALSE; DectrionMove=FALSE; EndPoint=point; CClientDC ddc(this);/* CDC MemDC; MemDC.CreateCompatibleDC(&ddc); MemDC.SelectObject(bitmap); long clr1=RGB(255,255,255); long color=MemDC.GetPixel(point.x ,point.y); xPil=point.x; ypil=point.y; MemDC.DeleteDC();*/// Scanpicture(color); SelRect.left=StartPoint.x; SelRect.top=StartPoint.y; SelRect.right=EndPoint.x; SelRect.bottom=EndPoint.y; if(!bDrawed) { oldselRect=CRect(0,0,0,0); ddc.LPtoDP(oldselRect); SelRect.NormalizeRect(); oldselRect.NormalizeRect(); ddc.DrawDragRect(SelRect,sz,oldselRect,sz ,&Drawbrush,NULL); oldselRect=SelRect; bDrawed=TRUE; DrawRect=SelRect; } DrawDragPoint(&ddc,DrawRect); COleControl::OnLButtonUp(nFlags, point);}void CPictureActiveCtrl::OnMouseMove(UINT nFlags, CPoint point) { // TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください CPoint testPoint; testPoint.x=point.x; testPoint.y=point.y; if(!mousedown) { if(rect[1].PtInRect(testPoint)) { dectrion=LEFTTOP;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE )); } else if(rect[2].PtInRect(testPoint)) { dectrion=UP;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS )); } else if(rect[3].PtInRect(testPoint)) { dectrion=RIGHTTOP;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENESW )); } else if(rect[4].PtInRect(testPoint)) { dectrion=RIGHT;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE )); } else if(rect[5].PtInRect(testPoint)) { dectrion=RIGHTB0TTOM;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE )); } else if(rect[6].PtInRect(testPoint)) { dectrion=DOWN;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS )); } else if(rect[7].PtInRect(testPoint)) { dectrion=LEFTBOTTOM;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENESW )); } else if(rect[8].PtInRect(testPoint)) { dectrion=LEFT;DectrionMove=1; ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE )); } else DectrionMove=0; } if(bDrawed && bPointmouse) { if(DectrionMove) { switch(dectrion) { case 1: DrawRect.top=point.y; DrawRect.left=point.x; break; case 2: //DrawRect=rectTemp; DrawRect.top=point.y; break; case 3: //DrawRect=rectTemp; DrawRect.right=point.x;DrawRect.top=point.y; break; case 4: //DrawRect=rectTemp; DrawRect.right=point.x; break; case 5: //DrawRect=rectTemp; DrawRect.bottom=point.y;DrawRect.right=point.x; break; case 6: //DrawRect=rectTemp; DrawRect.bottom=point.y; break; case 7: //DrawRect=rectTemp; DrawRect.left=point.x; DrawRect.bottom=point.y; break; case 8: //DrawRect=rectTemp; DrawRect.left=point.x; break; default: break; } } else { DectrionMove=0; holdCursor=::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS)); DrawRect.bottom=point.y; DrawRect.right=point.x; } CClientDC ddc(this); ddc.LPtoDP(oldselRect); DrawRect.NormalizeRect(); oldselRect.NormalizeRect(); ddc.DrawDragRect(DrawRect,sz,oldselRect,sz ,&Drawbrush,NULL); oldselRect=DrawRect; } COleControl::OnMouseMove(nFlags, point);}BOOL CPictureActiveCtrl::DrawDragPoint(CDC *cdc, CRect rectBox){ CBrush brush; brush.CreateSolidBrush(RGB(255,0,0)); rect[1]=GetRect(rectBox.left,rectBox.top); rect[2]=GetRect((rectBox.left+rectBox.right)/2,rectBox.top); rect[3]=GetRect(rectBox.right,rectBox.top); rect[4]=GetRect(rectBox.right,(rectBox.top+rectBox.bottom)/2); rect[5]=GetRect(rectBox.right,rectBox.bottom); rect[6]=GetRect((rectBox.left+rectBox.right)/2,rectBox.bottom); rect[7]=GetRect(rectBox.left,rectBox.bottom); rect[8]=GetRect(rectBox.left,(rectBox.top+rectBox.bottom)/2); for(int i=1;i<9;i++) { cdc->FillRect(rect[i],&brush); // MetaFileDC->FillRect(rect[i],&brush); cdc->UpdateColors(); // MetaFileDC->UpdateColors(); } return true;}CRect CPictureActiveCtrl::GetRect(long x, long y){ CRect rect1; rect1.bottom=y+2; rect1.top=y-2; rect1.left=x-2; rect1.right=x+2; return rect1;} 年底散分100 祝:新年快乐,万事如意,工作顺利! 讨论:QQ与别人聊天的窗口属于? 超菜问题怎样加载自己定义的函数? 关于进程间通讯的问题。请各位大侠帮忙。 关于qq,msn,yahoo messager,网易泡泡的通讯协议 用msxml写一个xml文档,怎样让输出文当清楚好看(就是包含TAB键空格和换行) MFC Dialog? 不知道如何调用编程Internet Explorer。各位指点一下。 关于拖放的问题 extern问题 super easy 的问题,在线等待帮助!! 关于在vc中调用c语言编写的dll文件的问题。
{
// TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
StartPoint=point;
mousedown=TRUE;
CClientDC ddc(this);
// OnDraw(&ddc,&Clientrect,NULL);
OnResetState();
if(DectrionMove)
{
bPointmouse=TRUE;
oldselRect=CRect(0,0,0,0);
ddc.LPtoDP(oldselRect);
DrawRect.NormalizeRect();
oldselRect.NormalizeRect();
ddc.DrawDragRect(DrawRect,sz,oldselRect,sz ,&Drawbrush,NULL);
oldselRect=DrawRect;
bDrawed=TRUE;
}
else
{
bDrawed=FALSE;
bPointmouse=FALSE;
DectrionMove=FALSE; }
COleControl::OnLButtonDown(nFlags, point);
}void CPictureActiveCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
mousedown=FALSE;
bPointmouse=FALSE;
DectrionMove=FALSE;
EndPoint=point;
CClientDC ddc(this);
/* CDC MemDC;
MemDC.CreateCompatibleDC(&ddc);
MemDC.SelectObject(bitmap);
long clr1=RGB(255,255,255);
long color=MemDC.GetPixel(point.x ,point.y);
xPil=point.x;
ypil=point.y;
MemDC.DeleteDC();*/
// Scanpicture(color); SelRect.left=StartPoint.x;
SelRect.top=StartPoint.y;
SelRect.right=EndPoint.x;
SelRect.bottom=EndPoint.y;
if(!bDrawed)
{
oldselRect=CRect(0,0,0,0);
ddc.LPtoDP(oldselRect);
SelRect.NormalizeRect();
oldselRect.NormalizeRect();
ddc.DrawDragRect(SelRect,sz,oldselRect,sz ,&Drawbrush,NULL);
oldselRect=SelRect;
bDrawed=TRUE;
DrawRect=SelRect;
}
DrawDragPoint(&ddc,DrawRect);
COleControl::OnLButtonUp(nFlags, point);
}void CPictureActiveCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
CPoint testPoint;
testPoint.x=point.x;
testPoint.y=point.y;
if(!mousedown)
{
if(rect[1].PtInRect(testPoint))
{
dectrion=LEFTTOP;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE ));
}
else if(rect[2].PtInRect(testPoint))
{
dectrion=UP;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS ));
}
else if(rect[3].PtInRect(testPoint))
{
dectrion=RIGHTTOP;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENESW ));
}
else if(rect[4].PtInRect(testPoint))
{
dectrion=RIGHT;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE ));
}
else if(rect[5].PtInRect(testPoint))
{
dectrion=RIGHTB0TTOM;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE ));
}
else if(rect[6].PtInRect(testPoint))
{
dectrion=DOWN;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS ));
}
else if(rect[7].PtInRect(testPoint))
{
dectrion=LEFTBOTTOM;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENESW ));
}
else if(rect[8].PtInRect(testPoint))
{
dectrion=LEFT;DectrionMove=1;
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE ));
}
else
DectrionMove=0;
}
if(bDrawed && bPointmouse)
{
if(DectrionMove)
{
switch(dectrion)
{
case 1:
DrawRect.top=point.y; DrawRect.left=point.x;
break;
case 2:
//DrawRect=rectTemp;
DrawRect.top=point.y; break;
case 3:
//DrawRect=rectTemp;
DrawRect.right=point.x;DrawRect.top=point.y; break;
case 4:
//DrawRect=rectTemp;
DrawRect.right=point.x; break;
case 5:
//DrawRect=rectTemp;
DrawRect.bottom=point.y;DrawRect.right=point.x; break;
case 6:
//DrawRect=rectTemp;
DrawRect.bottom=point.y; break;
case 7:
//DrawRect=rectTemp;
DrawRect.left=point.x; DrawRect.bottom=point.y; break;
case 8:
//DrawRect=rectTemp;
DrawRect.left=point.x; break;
default:
break;
}
}
else
{
DectrionMove=0;
holdCursor=::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
DrawRect.bottom=point.y;
DrawRect.right=point.x;
}
CClientDC ddc(this);
ddc.LPtoDP(oldselRect);
DrawRect.NormalizeRect();
oldselRect.NormalizeRect();
ddc.DrawDragRect(DrawRect,sz,oldselRect,sz ,&Drawbrush,NULL);
oldselRect=DrawRect;
}
COleControl::OnMouseMove(nFlags, point);
}BOOL CPictureActiveCtrl::DrawDragPoint(CDC *cdc, CRect rectBox)
{
CBrush brush;
brush.CreateSolidBrush(RGB(255,0,0));
rect[1]=GetRect(rectBox.left,rectBox.top);
rect[2]=GetRect((rectBox.left+rectBox.right)/2,rectBox.top);
rect[3]=GetRect(rectBox.right,rectBox.top); rect[4]=GetRect(rectBox.right,(rectBox.top+rectBox.bottom)/2);
rect[5]=GetRect(rectBox.right,rectBox.bottom); rect[6]=GetRect((rectBox.left+rectBox.right)/2,rectBox.bottom);
rect[7]=GetRect(rectBox.left,rectBox.bottom);
rect[8]=GetRect(rectBox.left,(rectBox.top+rectBox.bottom)/2);
for(int i=1;i<9;i++)
{
cdc->FillRect(rect[i],&brush);
// MetaFileDC->FillRect(rect[i],&brush);
cdc->UpdateColors();
// MetaFileDC->UpdateColors();
}
return true;
}CRect CPictureActiveCtrl::GetRect(long x, long y)
{
CRect rect1;
rect1.bottom=y+2; rect1.top=y-2;
rect1.left=x-2; rect1.right=x+2;
return rect1;
}