基本的皮筋用法
MFC代码:
BOOL CDlgTest::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
m_tracker.m_nStyle = CRectTracker::resizeOutside | CRectTracker::solidLine;
m_tracker.m_nHandleSize = 6;
m_tracker.m_rect.SetRect(0,0,100,100);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
BOOL CDlgTest::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (m_tracker.SetCursor(pWnd, nHitTest)) {
return TRUE;
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CDlgTest::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (m_tracker.HitTest(point) < 0) {
//m_tracker.TrackRubberBand(this, point);
} else {
m_tracker.Track(this, point, TRUE);
m_edit.MoveWindow(&m_tracker.m_rect);
if (m_lastWidth > 0) {
float x = (float)m_tracker.m_rect.Size().cx / (float) m_lastWidth;
int n = x * 100;
m_edit.PostMessage(EM_SETZOOM, n, 100);
}
else {
m_lastWidth = m_tracker.m_rect.Size().cx;
}
}
Invalidate();
CDialog::OnLButtonDown(nFlags, point);
}
void CDlgTest::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CDialog::OnPaint()
m_tracker.Draw(&dc);
}