Thread: horizontal scrollbar in listbox

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    58

    horizontal scrollbar in listbox

    Hello all
    im trying to implement horizontal scrollbar in listbox windows
    with out any success
    this is how my create list box looks like :
    Code:
      // Create a child listbox control.
            hWndList = CreateWindowEx(0,
                            "Listbox",
                            "",
                            WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | LBS_NOINTEGRALHEIGHT,
                            0,
                            0,
                            CW_USEDEFAULT,
                            CW_USEDEFAULT,
                            hWndMain,
                            NULL,
                            hinstance,
                            NULL);
    and it does create the scroll bar , but when i try to capture the event (WM_HSCROLL)
    that looks like this :
    Code:
     case WM_HSCROLL:
          {
             int nScrollCode = (int) LOWORD(wParam);  // scroll bar value
             int nPos = (short int) HIWORD(wParam);   // scroll box position
    		  
             SetScrollPos(hWndList,
                          nScrollCode,
                          nPos,
                          true);
    		  
    		 
          }
    but the scroll bar does not moving any where when i click or try to move it to the right .
    what im missing here ?

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    I believe you need to send the LB_SETHORIZONTALEXTENT message to the list box.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    58

    where do i need to do it ?

    And how ?

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Google is your friend. Do some research yourself.

  5. #5
    Registered User
    Join Date
    Sep 2010
    Posts
    1
    Quote Originally Posted by umen242 View Post
    Hello all
    im trying to implement horizontal scrollbar in listbox windows
    with out any success
    this is how my create list box looks like :
    Code:
      // Create a child listbox control.
            hWndList = CreateWindowEx(0,
                            "Listbox",
                            "",
                            WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | LBS_NOINTEGRALHEIGHT,
                            0,
                            0,
                            CW_USEDEFAULT,
                            CW_USEDEFAULT,
                            hWndMain,
                            NULL,
                            hinstance,
                            NULL);
    and it does create the scroll bar , but when i try to capture the event (WM_HSCROLL)
    that looks like this :
    Code:
     case WM_HSCROLL:
          {
             int nScrollCode = (int) LOWORD(wParam);  // scroll bar value
             int nPos = (short int) HIWORD(wParam);   // scroll box position
    		  
             SetScrollPos(hWndList,
                          nScrollCode,
                          nPos,
                          true);
    		  
    		 
          }
    but the scroll bar does not moving any where when i click or try to move it to the right .
    what im missing here ?


    use this

    HWND h_ListBox;

    h_ListBox = CreateWindow(
    _T("LISTBOX"),
    _T(""),
    (WS_HSCROLL | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP),
    10,10,270,160,
    hWnd,
    (HMENU)8004,
    GetModuleHandle(NULL),
    NULL
    );

    int SizeOfHBListBox = 1024;
    SendDlgItemMessage(hWnd,8004,(UINT) LB_SETHORIZONTALEXTENT,(WPARAM)SizeOfHBListBox,(LP ARAM)0);
    Last edited by Rishi Aneja; 09-17-2010 at 01:26 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to active the scrollbar on ListBox manually ?
    By ralph23 in forum C++ Programming
    Replies: 2
    Last Post: 03-10-2006, 09:29 PM
  2. CTreeCtrl horizontal scrollbar
    By eXistenZ in forum C++ Programming
    Replies: 0
    Last Post: 08-21-2005, 11:35 AM
  3. How to cast a ListBox item to an int for a switch statment?
    By Swaine777 in forum C++ Programming
    Replies: 8
    Last Post: 09-26-2004, 08:52 PM
  4. Listbox control with horizontal scrollbar
    By Ward in forum Windows Programming
    Replies: 1
    Last Post: 02-06-2002, 10:35 AM
  5. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 08:28 AM