我已经建了一个链表,里面放了我用ondraw函数在屏幕上画的每张bmp左上角的位置,使用用CPoint类型。在OnLButtonDblClk函数里我写了获取双击鼠标左键后,遍历该链表,查找point是否有在图片范围内的。如:
if(point.x>=100&&point.x<=200&&point.y>=100&&point.y<=200)
MessageBox("You have clicked me.");
但用滚动条后,用了CSROLLVIEW作为base class,滚动滚动条后,整个屏幕就发生了位置,双击鼠标后就没反应了。怎么处理啊。在线等。
if(point.x>=100&&point.x<=200&&point.y>=100&&point.y<=200)
MessageBox("You have clicked me.");
但用滚动条后,用了CSROLLVIEW作为base class,滚动滚动条后,整个屏幕就发生了位置,双击鼠标后就没反应了。怎么处理啊。在线等。
void CMyView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// Get the minimum and maximum scroll-bar positions.
int minpos;
int maxpos;
pScrollBar->GetScrollRange(&minpos, &maxpos);
maxpos = pScrollBar->GetScrollLimit(); // Get the current position of scroll box.
int curpos = pScrollBar->GetScrollPos(); // Determine the new position of scroll box.
switch (nSBCode)
{
case SB_LEFT: // Scroll to far left.
curpos = minpos;
break; case SB_RIGHT: // Scroll to far right.
curpos = maxpos;
break; case SB_ENDSCROLL: // End scroll.
break; case SB_LINELEFT: // Scroll left.
if (curpos > minpos)
curpos--;
break; case SB_LINERIGHT: // Scroll right.
if (curpos < maxpos)
curpos++;
break; case SB_PAGELEFT: // Scroll one page left.
{
// Get the page size.
SCROLLINFO info;
pScrollBar->GetScrollInfo(&info, SIF_ALL);
if (curpos > minpos)
curpos = max(minpos, curpos - (int) info.nPage);
}
break; case SB_PAGERIGHT: // Scroll one page right.
{
// Get the page size.
SCROLLINFO info;
pScrollBar->GetScrollInfo(&info, SIF_ALL); if (curpos < maxpos)
curpos = min(maxpos, curpos + (int) info.nPage);
}
break; case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
curpos = nPos; // of the scroll box at the end of the drag operation.
break; case SB_THUMBTRACK: // Drag scroll box to specified position. nPos is the
curpos = nPos; // position that the scroll box has been dragged to.
break;
} // Set the new position of the thumb (scroll box).
pScrollBar->SetScrollPos(curpos); CView::OnHScroll(nSBCode, nPos, pScrollBar);
}
即使获得了滚动条位置后,能否解决我上面一贴里写的问题啊?
{
// 调整点的位置,使它跟你的视图逻辑坐标一致
CClientDC dc(this);
PrepareDC(&dc);
DPtoLP(&point);
....}