MFC中的CRectTracker问题 [英] CRectTracker problem in MFC
本文介绍了MFC中的CRectTracker问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在Scrollview中实现了CRectTracker.问题是跟踪器无需滚动即可正常工作.但是,当我滚动窗口时,跟踪器消失了.任何人都可以提出解决我问题的建议.
I had implemented a CRectTracker in Scrollview. The problem is the tracker works fine without scrolling. But when I scroll the window the tracker disappears. Could anyone give suggestions to solve my problem.
CFinalPDoc* pDoc = GetDocument();
tracker.m_nStyle = CRectTracker::dottedLine^CRectTracker::resizeOutside;
//if not hitting any handle
if(tracker.HitTest(point)<0)
{
//if mouse move and rectangle is not empty
if(tracker.TrackRubberBand(this,point))
{
RedrawWindow();
//make width and height positive and set trackerRect
tracker.m_rect.NormalizeRect();
trackerRect = &tracker.m_rect;
//show resize handles
tracker.GetHandleMask();
//draw rectangle
CClientDC dc(this);
tracker.Draw(&dc);
}
else //no rubber band
{
//make width and height positive and set trackerRect
tracker.m_rect.NormalizeRect();
trackerRect = &tracker.m_rect;
((CStatic*)GetDlgItem(IDC_PICTURE))->SetBitmap(*currentBmp);
}
}
推荐答案
可能是,
鼠标单击仅设置元素的标记标志...
...然后,在您的CXXXView::OnDraw(CDC*)
中,您可以使用标志
将跟踪器绘制到标记的元素周围:)
Probably,
the mouse click sholud set the element''s marking flag only...
...then, in yourCXXXView::OnDraw(CDC*)
, you could use the flag
to draw the tracker arount the marked element(s) :)
/*afx_msg*/ void CYourView::OnMouseDown(UINT uiFlags, CPoint point)
{
CPoint cptAbsoluteViewPosition(point + GetScrollPosition());
CYourDoc* pcDoc(GetDocument);
if (pcDoc) {
CYourDocElementBase* pcElement(pcDoc->FindElementByPos(cptAbsoluteViewPosition));
if (pcElement) {
pcElement->SetMarked(true);
Invalidate();
}
}
CScrollView::OnMouseDown(uiFlags, point);
}
/*virtual*/ void CYourView::OnDraw(CDC* pDC)
{
//..
POSITION pos(pcDoc->GetFirstElementPos());
while (pos) {
CYourDocElementBase* pcElement(pcDoc->GetNextElement(pos));
if (pcElement) {
CRect crElement(pcElement->GetElemRect());
if (/*IsElemRectClipped(pDC, crElement)*/) {
pcElement->Draw(pDC);
if (pcElement->IsMarked()) {
// use the crElement to draw the tracker there :)
}
}
}
}
//..
}
这篇关于MFC中的CRectTracker问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文