Sign in to follow this  
b1gjo3

help with ScrollBar

Recommended Posts

b1gjo3    213
for some reason i cannot get SB_PAGEDOWN or SB_THUMBTRACK to work at all. The bar just stays at the same place. can someone point me in the right direction and tell me what exactly im doing wrong?
void PictureBox::HandleMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
	if (message != WM_VSCROLL || message != WM_HSCROLL)
	{
		switch (message)
		{
			SCROLLINFO info;
			case WM_VSCROLL:
			{
				switch (wParam)
				{
					//up arrow
					case SB_LINEUP:
						SetScrollPos(myVScroll->GetHWND(), SB_CTL, myVScroll->GetValue() - 1, TRUE);
						InvalidateRect(myHwnd, 0, TRUE);
						break;

					//down arrow
					case SB_LINEDOWN:
						SetScrollPos(myVScroll->GetHWND(), SB_CTL, myVScroll->GetValue() + 1, TRUE);
						InvalidateRect(myHwnd, 0, TRUE);
						break;

					case SB_PAGEDOWN:
						ZeroMemory(&info, sizeof(info));
						info.cbSize = sizeof(SCROLLINFO);
						info.fMask = SIF_ALL;
						GetScrollInfo(myVScroll->GetHWND(), SB_CTL, &info);
						info.nPos += info.nPage;
						SetScrollInfo(myVScroll->GetHWND(), SB_CTL, &info, TRUE);
						break;

					//scroll
					case SB_THUMBTRACK:
						ZeroMemory(&info, sizeof(info));
						info.cbSize = sizeof(SCROLLINFO);
						info.fMask = SIF_TRACKPOS;
						GetScrollInfo(myVScroll->GetHWND(), SB_CTL, &info);
						SetScrollPos(myVScroll->GetHWND(), SB_CTL, info.nTrackPos, TRUE);
						InvalidateRect(myHwnd, 0, TRUE);
						break;
				}
			}
			break;

Share this post


Link to post
Share on other sites
b1gjo3    213
i fixed it. all i had to do was change "switch (wParam)" to "switch (LOWORD(wParam))" lol

heres the final code for this function

void PictureBox::HandleMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message != WM_VSCROLL || message != WM_HSCROLL)
{
switch (message)
{
case WM_VSCROLL:
{
switch (LOWORD(wParam))
{
//up arrow
case SB_LINEUP:
myVScroll->SetPos(myVScroll->GetValue() - 1);
break;

//down arrow
case SB_LINEDOWN:
myVScroll->SetPos(myVScroll->GetValue() + 1);
break;

//page down
case SB_PAGEDOWN:
myVScroll->MovePage(TRUE);
break;

//page up
case SB_PAGEUP:
myVScroll->MovePage(FALSE);
break;

//scroll
case SB_THUMBTRACK:
SCROLLINFO info;
info.cbSize = sizeof(info);
info.fMask = SIF_TRACKPOS | SIF_POS;
GetScrollInfo(myVScroll->GetHWND(), SB_CTL, &info);
info.nPos = info.nTrackPos;
info.fMask = SIF_POS;
SetScrollInfo(myVScroll->GetHWND(), SB_CTL, &info, TRUE);
break;
}

InvalidateRect(myHwnd, &drawArea, TRUE);
}
break;

case WM_HSCROLL:
{
switch (LOWORD(wParam))
{
//left arrow
case SB_LINELEFT:
myHScroll->SetPos(myHScroll->GetValue() - 1);
break;

//right arrow
case SB_LINERIGHT:
myHScroll->SetPos(myHScroll->GetValue() + 1);
break;

case SB_PAGELEFT:
myHScroll->MovePage(FALSE);
break;

case SB_PAGERIGHT:
myHScroll->MovePage(TRUE);
break;

case SB_THUMBTRACK:
SCROLLINFO info;
info.cbSize = sizeof(info);
info.fMask = SIF_TRACKPOS | SIF_POS;
GetScrollInfo(myHScroll->GetHWND(), SB_CTL, &info);
info.nPos = info.nTrackPos;
info.fMask = SIF_POS;
SetScrollInfo(myHScroll->GetHWND(), SB_CTL, &info, TRUE);
break;
}

InvalidateRect(myHwnd, &drawArea, TRUE);
}
break;
}
}
}

Share this post


Link to post
Share on other sites
marius1930    119
Not to be a pain.. but you really should install the MSDN help files.

Quote:
WM_HSCROLL Notification

wParam
The low-order word specifies a scroll bar value that indicates the user's scrolling request. This word can be one of the following values.

The high-order word specifies the current position of the scroll box if the low-order word is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, this word is not used.

Share this post


Link to post
Share on other sites
b1gjo3    213
Quote:
Original post by marius1930
Not to be a pain.. but you really should install the MSDN help files.

Quote:
WM_HSCROLL Notification

wParam
The low-order word specifies a scroll bar value that indicates the user's scrolling request. This word can be one of the following values.

The high-order word specifies the current position of the scroll box if the low-order word is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, this word is not used.


that doesn't tell me anything really..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this