我想使用滚动条滚动图像,但是当我在OnHScroll方法中使用scrollwindow()函数时,它仅滚动出现在对话框中的按钮而不是图像。 我已经使用bitblt和stretchblt函数来放大图像使用设备上下文。我认为通过使用直流信息我们可以滚动图像,但我不知道我这样做。水平滚动图像
OnHScroll函数的代码如下给出:
void CImgVeiwer::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pcrollBar)
{
// TODO: Add your message handler code here and/or call default
int minpos;
int maxpos;
GetScrollRange(SB_HORZ, &minpos, &maxpos);
maxpos = GetScrollLimit(SB_HORZ);
CurPos = GetScrollPos(SB_HORZ);
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;
GetScrollInfo(SB_HORZ, &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;
GetScrollInfo(SB_HORZ, &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).
m_HsrollFlag = TRUE;
SetScrollPos(SB_HORZ,CurPos);
ScrollWindow(-CurPos,0,0,0);
Invalidate();
CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}
在此先感谢
在传递lpRect,lpClipRect参数时,它将滚动图像以及出现在对话框中的按钮。 – user3148898
如何在OnPaint mehtod – user3148898
中重新绘制图像需要更多细节。图像如何显示? (它是在单独的控件中,还是绘制在对话框背景中,或者绘制在OnPaint中?)图像顶部的按钮是? –