|
-
November 23rd, 2011, 10:05 AM
#1
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.
-
November 23rd, 2011, 12:56 PM
#2
Re: GetScrollInfo returns nothing on SB_PAGELEFT
Because, according to the MSDN for the SB_PAGELEFT message:
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
-
November 23rd, 2011, 01:00 PM
#3
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
-
November 24th, 2011, 08:34 AM
#4
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;
-
November 24th, 2011, 10:09 AM
#5
Re: GetScrollInfo returns nothing on SB_PAGELEFT
 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.
Victor Nijegorodov
-
November 24th, 2011, 11:08 AM
#6
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.
-
November 26th, 2011, 02:56 AM
#7
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.
Last edited by ovidiucucu; November 26th, 2011 at 11:01 AM.
-
November 30th, 2011, 09:26 AM
#8
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|