UI: Form editor && use CRectTracker to allow user drag/move/resize graphics
2011-03-04 20:44
344 查看
Init:
m_rectTracker.m_rect.SetRect(0,0,100,100);
m_rectTracker.m_nStyle=CRectTracker::resizeInside|CRectTracker::dottedLine;
onDraw:
m_rectTracker.GetTrueRect(&rect);
//if(bDraw)
dc.Ellipse (rect);//画椭圆;
//Draw tracking rectangle.
m_rectTracker.Draw(&dc);//这句画才真正的将这个四边形画出来; void CRectTrackDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int nIn; //定义一个鼠标的点击值;
nIn=m_rectTracker.HitTest(point); //看看点到了哪了
if(nIn<0) //不在四边形区域内;
{
CRectTracker temp;
temp.TrackRubberBand(this,point,TRUE);
temp.m_rect.NormalizeRect();
CRectTracker interRect;
//在建立一个CRectTracker;用于记录鼠标与椭圆的交集。
if(interRect.m_rect.IntersectRect(temp.m_rect,m_rectTracker.m_rect))
bDraw=TRUE; //如果有交集,则画四边形的边界,说明选择了椭圆
else bDraw=FALSE;
Invalidate(); //引起OnDraw函数的发生;
}
else
//在四边形区域内:
{
CClientDC dc(this);
m_rectTracker.Draw(&dc);
m_rectTracker.Track(this,point,TRUE);
// Track()是CRectTracker中最富魅力的函数。它时时的改变调用者的m_rect;
bDraw=TRUE;
Invalidate();
}
CDialog::OnLButtonDown(nFlags, point);
}
BOOL CRectTrackDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
if (pWnd == this && m_rectTracker.SetCursor(this, nHitTest))
return TRUE;
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
- Form editor
- http://www.codeproject.com/KB/cs/SharpFormEditorDemo.aspx
- http://www.codeproject.com/KB/atl/FormDesigner.aspx
- http://www.codeproject.com/KB/miscctrl/diagrameditor.aspx
- http://www.icsharpcode.net/OpenSource/SD/
m_rectTracker.m_rect.SetRect(0,0,100,100);
m_rectTracker.m_nStyle=CRectTracker::resizeInside|CRectTracker::dottedLine;
onDraw:
m_rectTracker.GetTrueRect(&rect);
//if(bDraw)
dc.Ellipse (rect);//画椭圆;
//Draw tracking rectangle.
m_rectTracker.Draw(&dc);//这句画才真正的将这个四边形画出来; void CRectTrackDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int nIn; //定义一个鼠标的点击值;
nIn=m_rectTracker.HitTest(point); //看看点到了哪了
if(nIn<0) //不在四边形区域内;
{
CRectTracker temp;
temp.TrackRubberBand(this,point,TRUE);
temp.m_rect.NormalizeRect();
CRectTracker interRect;
//在建立一个CRectTracker;用于记录鼠标与椭圆的交集。
if(interRect.m_rect.IntersectRect(temp.m_rect,m_rectTracker.m_rect))
bDraw=TRUE; //如果有交集,则画四边形的边界,说明选择了椭圆
else bDraw=FALSE;
Invalidate(); //引起OnDraw函数的发生;
}
else
//在四边形区域内:
{
CClientDC dc(this);
m_rectTracker.Draw(&dc);
m_rectTracker.Track(this,point,TRUE);
// Track()是CRectTracker中最富魅力的函数。它时时的改变调用者的m_rect;
bDraw=TRUE;
Invalidate();
}
CDialog::OnLButtonDown(nFlags, point);
}
BOOL CRectTrackDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
if (pWnd == this && m_rectTracker.SetCursor(this, nHitTest))
return TRUE;
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
- Form editor
- http://www.codeproject.com/KB/cs/SharpFormEditorDemo.aspx
- http://www.codeproject.com/KB/atl/FormDesigner.aspx
- http://www.codeproject.com/KB/miscctrl/diagrameditor.aspx
- http://www.icsharpcode.net/OpenSource/SD/
相关文章推荐
- How to use the windows active directory to authenticate user via logon form 如何自定义权限系统,使用 active directory验证用户登录
- Must use 'struct' tag to refer to type 'tagCommonUserInfo'
- HTML5 touche vents drag to move & AF actionsheet by longTap
- 关于Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances的错误
- Swift中推送通知设置:Binary operator '|' cannot be applied to two UIUserNotificationType operands 错误解决
- KendoUI how to use local data, not form url
- How to access UI controls from a user defined class (CFormView based SDI application)
- Q&A: Putting MySQL Fabric to use
- corresponds to your MySQL server version for the right syntax to use near 'describe)values(225,0,'aa
- Note On <Programming Entity Framework 2nd Edition> -01: How to Use LINQPad 4.5
- use asp to know the table's struction of sql servler
- [XAF] How to define a business class at runtime or allow end-users to configure its members via the application UI?
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR: "This virtual machine appears to be in use"
- Use emacs & Graphviz to plot data structure
- mysql root 进入出现ERROR 1044(42000):Access denied for user ''@'localhost' to database 'mysql'
- How to use PUnit & CUnit
- [转]POI : How to Create and Use User Defined Functions
- [Redux-Observable && Unit Testing] Use tests to verify updates to the Redux store (rxjs scheduler)
- Android开发无法打开模拟器的问题:use '@foo' to launch a virtual device named