CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2006
    Posts
    75

    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.

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    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

  3. #3
    Join Date
    Feb 2002
    Posts
    4,640

    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

  4. #4
    Join Date
    Jul 2006
    Posts
    75

    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;

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: GetScrollInfo returns nothing on SB_PAGELEFT

    Quote Originally Posted by Sh@dow View Post
    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

  6. #6
    Join Date
    Jul 2006
    Posts
    75

    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.

  7. #7
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  8. #8
    Join Date
    Jul 2006
    Posts
    75

    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
  •  





Click Here to Expand Forum to Full Width

Featured