bka*_*sbk -1
我认为您正在谈论如何处理 WM_VSCROLL/WM_HSCROLL 事件的示例。如果是这样,第一步是处理该事件。您不应使用该调用的 HIWORD(wParam) 值,而应使用 GetScrollInfo、GetScrollPos 和 GetScrollRange 函数。
以下是MSDN - 使用滚动条截取的示例代码。例如,xCurrentScroll 是通过调用 GetScrollPos() 之前确定的。
int xDelta; // xDelta = new_pos - current_pos
int xNewPos; // new position
int yDelta = 0;
switch (LOWORD(wParam)) {
// User clicked the scroll bar shaft left of the scroll box.
case SB_PAGEUP:
xNewPos = xCurrentScroll - 50;
break;
// User clicked the scroll bar shaft right of the scroll box.
case SB_PAGEDOWN:
xNewPos = xCurrentScroll + 50;
break;
// User clicked the left arrow.
case SB_LINEUP:
xNewPos = xCurrentScroll - 5;
break;
// User clicked the right arrow.
case SB_LINEDOWN:
xNewPos = xCurrentScroll + 5;
break;
// User dragged the scroll box.
case SB_THUMBPOSITION:
xNewPos = HIWORD(wParam);
break;
default:
xNewPos = xCurrentScroll;
}
[...]
// New position must be between 0 and the screen width.
xNewPos = max(0, xNewPos);
xNewPos = min(xMaxScroll, xNewPos);
[...]
// Reset the scroll bar.
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = xCurrentScroll;
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6259 次 |
| 最近记录: |