Jump to content
  • Advertisement
Sign in to follow this  
b1gjo3

help with ScrollBar

This topic is 3718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
no i havnt >< and now that parts fixed, thank you. but what bout the SB_THUMBTRACK?

Share this post


Link to post
Share on other sites
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!