GetScrollInfo returns nothing on SB_PAGELEFT
Hi everyone,
I have searched the forum but found nothing related to my problem.
I'm using a horizontal scroll bar in a dialog box. I want to process SB_PAGELEFT message.
When WM_HSCROLL arrives mesage i check LOWORD(wParam) and if it is SB_PAGELEFT i'm trying to get position of a scroll bar. But GetScrollInfo returns nothing.
Here is the source:
Code:
HWND slider = GetDlgItem(hwndDlg,IDC_SLIDER);
SCROLLINFO info;
ZeroMemory(&info,sizeof(info));
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_ALL;
GetScrollInfo(slider,SB_CTL,&info);
SetDlgItemInt(hwndDlg,IDC_EDIT1,info.nPos,false);
info.nPos is invalid.
On SB_THUMBPOSITION I'm using HIWORD(wParam) as a position of a scroll bar. Why i can't get the same on SB_PAGELEFT is a big mystery to me.
Re: GetScrollInfo returns nothing on SB_PAGELEFT
Because, according to the MSDN for the SB_PAGELEFT message:
Quote:
Parameters
wParam
The HIWORD specifies the current position of the scroll box if the LOWORD is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, this word is not used.
Viggy
Re: GetScrollInfo returns nothing on SB_PAGELEFT
And, according to the MSDN for GetScrollInfo, I don't see an SIF_ALL mask. Have you tried just passing the SIF_POS mask?
Viggy
Re: GetScrollInfo returns nothing on SB_PAGELEFT
Yeah, i have change my code to SIF_POS and still GetScrollInfo returns nothing. No Errors as well.
Code:
case SB_PAGELEFT:
{
HWND slider = GetDlgItem(hwndDlg,IDC_SLIDER);
SCROLLINFO info;
ZeroMemory(&info,sizeof(info));
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_POS;
GetScrollInfo(slider,SB_CTL,&info);
SetDlgItemInt(hwndDlg,IDC_EDIT1,info.nPos,false);
}
break;
Re: GetScrollInfo returns nothing on SB_PAGELEFT
Quote:
Originally Posted by
Sh@dow
GetScrollInfo returns nothing. No Errors as well.
Define "nothing". What is the exact return value of GetScrollInfo? If it is zero then you should call GetLastError to get extended error information. :cool:
Re: GetScrollInfo returns nothing on SB_PAGELEFT
The structure is initialized to 0 before call. After GetScrollInfo the structure is the same as before calling GetScrollInfo. GetScrollInfo returns 1. GetLastError returns 0. So it seems everything is fine but i can't see any value in the structure.
Re: GetScrollInfo returns nothing on SB_PAGELEFT
It has no sense to call GetScrollInfo for a trackbar (slider) control, because... it has not a scrollbar. :)
Instead, send TBM_xxx messages.
Example
Code:
case TB_PAGEUP:
{
int nMinPos = ::SendMessage(hWndSlider, TBM_GETRANGEMIN, 0, 0);
int nMaxPos = ::SendMessage(hWndSlider, TBM_GETRANGEMAX, 0, 0);
int nPos = ::SendMessage(hWndSlider, TBM_GETPOS, 0, 0);
// ...
}
For more info, see Trackbar.
[ later edit ]
I guess, this topic is about a slider and not about a scrollbar control, given the ID name IDC_SLIDER.
Re: GetScrollInfo returns nothing on SB_PAGELEFT
>>I guess, this topic is about a slider and not about a scrollbar control, given the ID name IDC_SLIDER.
That is my mistake. I mixed this two different things.
Thanks ovidiucucu for help.