Z
ZenMaster
Hello, can anyone help me figure out what may be wrong
with my code -
In VC++ 6.0 Ive created a ScrollBar using :
--------------------------------------------
hwndScrollHue = CreateWindowEx
(WS_EX_OVERLAPPEDWINDOW, "SCROLLBAR", (LPSTR) NULL,
WS_CHILD | SBS_HORZ, 5, 100, 80, 16, hForm, (HMENU) NULL,
hInstance, (LPVOID) NULL);
ShowWindow(hwndScrollHue, SW_SHOWNORMAL);
---------------------------------------------
and then in the message loop:
---------------------------------------------
case WM_HSCROLL:
int xNewPos; // new position
switch (LOWORD(wParam))
{
// User clicked the shaft left of the scroll box.
case SB_PAGEUP:
xNewPos = xCurrentScroll - 50;
break;
// User clicked the 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;
};
if (xNewPos == xCurrentScroll)
break;
xCurrentScroll = xNewPos;
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMax = 300;
si.nMin = 0;
si.nPage = 4;
si.nPos = xCurrentScroll;
SetScrollInfo(hwndScrollHue, SB_HORZ, &si, TRUE);
InvalidateRect( hwndScrollHue, NULL, TRUE );
--------------------------------------------------------
I tried to fix up the scrollbar(s) according to MDSN and
some tutorials.
it doesnt really work/update the scroll bar with the new
position, and also renders the scrollbar over the old one
shifted up a few pixels up more, which is weird. Does
anyone know what I missed out or has such working code?
maybe is due to libraries or something??? I even put a
message box/debug statement and used GetScrollInfo to get
the updated position and it was updated as per wanted. Can
anyone figure out whats wrong? Thanks.
ZenMaster
with my code -
In VC++ 6.0 Ive created a ScrollBar using :
--------------------------------------------
hwndScrollHue = CreateWindowEx
(WS_EX_OVERLAPPEDWINDOW, "SCROLLBAR", (LPSTR) NULL,
WS_CHILD | SBS_HORZ, 5, 100, 80, 16, hForm, (HMENU) NULL,
hInstance, (LPVOID) NULL);
ShowWindow(hwndScrollHue, SW_SHOWNORMAL);
---------------------------------------------
and then in the message loop:
---------------------------------------------
case WM_HSCROLL:
int xNewPos; // new position
switch (LOWORD(wParam))
{
// User clicked the shaft left of the scroll box.
case SB_PAGEUP:
xNewPos = xCurrentScroll - 50;
break;
// User clicked the 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;
};
if (xNewPos == xCurrentScroll)
break;
xCurrentScroll = xNewPos;
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMax = 300;
si.nMin = 0;
si.nPage = 4;
si.nPos = xCurrentScroll;
SetScrollInfo(hwndScrollHue, SB_HORZ, &si, TRUE);
InvalidateRect( hwndScrollHue, NULL, TRUE );
--------------------------------------------------------
I tried to fix up the scrollbar(s) according to MDSN and
some tutorials.
it doesnt really work/update the scroll bar with the new
position, and also renders the scrollbar over the old one
shifted up a few pixels up more, which is weird. Does
anyone know what I missed out or has such working code?
maybe is due to libraries or something??? I even put a
message box/debug statement and used GetScrollInfo to get
the updated position and it was updated as per wanted. Can
anyone figure out whats wrong? Thanks.
ZenMaster