VC++ 6.0 - ScrollBar not functioning properly!

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
 
Joined
Dec 18, 2007
Messages
1
Reaction score
0
scroll bar VC++

Mr.ZenMaster

Could you please update me if you were able to find a solution for your post. I have exactly the same issue as indicated by you. Any help in this regard would be greatly appreciated.

Regards,
krgoutham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top