界面高手请入

zzdaa 2002-05-03 05:05:00
我用CRectTracker做类似于Acdsee那样的橡皮筋矩形选框的时候,当橡皮筋移动到窗口可视部分以外的时候,CScrollview的滚动条不能滚动,于是我手动加上了滚动的代码,但这个时候,拖动过程中的矩形框却显示不出来了,请问各位对这个问题有了解吗?我估计是由于视图滚动造成了坐标系统不一致引起的,请那个知道的帮忙解决一下这个问题
...全文
84 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
King_Cpp 2002-05-06
  • 打赏
  • 举报
回复
还是帮你顶一把吧!!
RodgerLiang 2002-05-06
  • 打赏
  • 举报
回复
I think you shall not use CRectTracker to response the message.
You can use function CRectTracker::Track to track the moving of the CRectTracker.
If you need I can give you a project about use the CRectTracker.
zzdaa 2002-05-03
  • 打赏
  • 举报
回复
rodgerliang,
我指的是在鼠标来回动的时候那个橡皮筋显示不正确,而CRectTracker本身截获了window的onlbuttondown消息,如何能在onDraw里面画的了呢?

hover(翔)(想弄几颗红星星玩玩)
这个东西真是让人头疼,反复查也找不到问题。
RodgerLiang 2002-05-03
  • 打赏
  • 举报
回复
I think you should draw the CRectTracker in ScrollView's OnDraw()
function. And calculate the position
Hover 2002-05-03
  • 打赏
  • 举报
回复
调试你的程序,看看m_rect的坐标是否正确.
zzdaa 2002-05-03
  • 打赏
  • 举报
回复
我把CrectTracker中的TrackerHandle的代码直接拷贝了出来,在消息循环的尾部加上了滚动视图的代码,问题就这样出现了。

for (;;)
{

MSG msg;
VERIFY(::GetMessage(&msg, NULL, 0, 0));

if (CWnd::GetCapture() != pWnd)
break;



switch (msg.message)
{
// handle movement/accept messages
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
rectOld = m_rect;
// handle resize cases (and part of move)
if (px != NULL)
*px = (int)(short)LOWORD(msg.lParam) - xDiff;
if (py != NULL)
*py = (int)(short)HIWORD(msg.lParam) - yDiff;

// handle move case
if (nHandle == hitMiddle)
{
m_rect.right = m_rect.left + nWidth;
m_rect.bottom = m_rect.top + nHeight;
}
// allow caller to adjust the rectangle if necessary
AdjustRect(nHandle, &m_rect);

// only redraw and callback if the rect actually changed!
m_bFinalErase = (msg.message == WM_LBUTTONUP);
if (!rectOld.EqualRect(&m_rect) || m_bFinalErase)
{
if (bMoved)
{
m_bErase = TRUE;
DrawTrackerRect(&rectOld, pWndClipTo, pDrawDC, pWnd);
}
OnChangedRect(rectOld);
if (msg.message != WM_LBUTTONUP)
bMoved = TRUE;
}
if (m_bFinalErase)
goto ExitLoop;

if (!rectOld.EqualRect(&m_rect))
{
m_bErase = FALSE;
DrawTrackerRect(&m_rect, pWndClipTo, pDrawDC, pWnd);
}
break;

// handle cancel messages
case WM_KEYDOWN:
if (msg.wParam != VK_ESCAPE)
break;
case WM_RBUTTONDOWN:
if (bMoved)
{
m_bErase = m_bFinalErase = TRUE;
DrawTrackerRect(&m_rect, pWndClipTo, pDrawDC, pWnd);
}
m_rect = rectSave;
goto ExitLoop;

// just dispatch rest of the messages
default:

DispatchMessage(&msg);
break;
}
((CPSChiperView*)pWnd)->GetClientRect(&ClientRect);
POINT ScrollPoint = ((CPSChiperView*)pWnd)->GetScrollPosition();
if (rectOld.right >ClientRect.right)
{
ScrollPoint.x += 10;
}
if (rectOld.right <ClientRect.left)
{
ScrollPoint.x -= 10;
}
if (rectOld.bottom <ClientRect.top)
{
ScrollPoint.y -= 10;
}
if (rectOld.bottom >ClientRect.bottom)
{
ScrollPoint.y += 10;
}
((CPSChiperView*)pWnd)->ScrollTo(ScrollPoint);
pDrawDC->SetViewportOrg(ScrollPoint);
pDrawDC->DPtoLP(m_rect);
((CPSChiperView*)pWnd)->Invalidate();

}
zzdaa 2002-05-03
  • 打赏
  • 举报
回复
终于有人回答了,谢谢,但是问题是出在这里

我在CRectTRacker的MFC代码里也看到了m_rect是窗口坐标,但是那句画线的语句DrwDragRect 却是直接画了m_rect,而DrawDragRect在msdn的帮助里是对逻辑坐标处理的呀,不明白。
RodgerLiang 2002-05-03
  • 打赏
  • 举报
回复
You can find the data member of CRectTracker::m_rect means :
The current position of the rectangle in client coordinates (pixels).

so if you scroll the view , you have to calculate the position.
Could you paste the code of drawing CRectTracker.

Hover 2002-05-03
  • 打赏
  • 举报
回复
将你获得的Mouse坐标用CDC的DPtoLP转换成逻辑坐标再处理
zzdaa 2002-05-03
  • 打赏
  • 举报
回复
高手呀,你快出现吧
zzdaa 2002-05-03
  • 打赏
  • 举报
回复
没有人知道吗?

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧