How can I use window's scrolling
Hello folks, I have to implement scrolling in my Win32 application.
I read the SDK documentation, it didn''t look too hard so I wrote code at once.
But my scrolling code doesn''t work at all. And I don''t know where''s the error...
Here''s the global variables:
SCROLLINFO si;
short nScreenMaxX;
short nScreenMaxY;
short nScrollX = 0;
short nScrollY = 0;
Here''s the message handler''s part which use the scrolling:
case WM_SIZE:
{
nScreenMaxX = LOWORD(lParam);
nScreenMaxY = HIWORD(lParam);
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = nScreenMaxX;
si.nPage = 50;
si.nPos = nScrollX;
SetScrollInfo(hWnd, SB_HORZ, &si, true);
InvalidateRect(hWnd, NULL, true);
return 0;
}
case WM_HSCROLL:
{
short nInc;
switch (LOWORD(wParam))
{
case SB_PAGEUP:
{ nInc = si.nPage; }
case SB_PAGEDOWN:
{ nInc = -si.nPage; }
case SB_LINELEFT:
{ nInc = -1; }
case SB_LINERIGHT:
{ nInc = 1; }
case SB_THUMBTRACK:
{ nInc = HIWORD(wParam) - nScrollX; }
default:
{ nInc = 0; }
}
nScrollX += nInc;
si.nPos = nScrollX;
SetScrollInfo(hWnd, SB_HORZ, &si, true);
InvalidateRect(hWnd, NULL, true);
return 0;
}
Does anyone see what''s going wrong?
Hi,
Did you create the window with scroll bar style:
WS_HSCROLL | WS_VSCROLL
did you call ShowScrollBar(TRUE); ?
Maybe one of these two things is the cause of your problems.
-- Gilad
Did you create the window with scroll bar style:
WS_HSCROLL | WS_VSCROLL
did you call ShowScrollBar(TRUE); ?
Maybe one of these two things is the cause of your problems.
-- Gilad
I created my window using the WS_HSCROLL and WS_VSCROLL tags, but I didn''t call the function ShowScrollBar.
I''m going to try to put it, I thought it was just a function to initialise scroll bars when they weren''t created with the window.
Thanks.
I''m going to try to put it, I thought it was just a function to initialise scroll bars when they weren''t created with the window.
Thanks.
Ah, scroll bars, the bane of windows programming (I swear, scroll bars have to be the absolute worst thing to program as far as the GUI goes).
here''s a snippet of my code that works. kind of in a rush right now, just cut and paste, so see if it makes any sense:
here''s a snippet of my code that works. kind of in a rush right now, just cut and paste, so see if it makes any sense:
|
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement