Results 1 to 9 of 9

Thread: [RESOLVED] Problem moving listbox horizontal lisbox scroller to the right

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Resolved [RESOLVED] Problem moving listbox horizontal lisbox scroller to the right

    Hi all i put a horizantal scroller for mylistbox but unfortuntally i can not use it sicne i have long data in my listbox and i can not move the tab for the horizantal listbox since the with of is big enought that does not allow any movment to right side!! Even if i try to make my listbox width big still i face problem. Is there a way to make the size of scroller tab smaller so i can move it to the right side ? I hope some one help me here.Thanks


    VB Code:
    1. Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, _
    2. ByVal bShow As Long) As Long
    3. Private Const SB_HORIZONTAL = 0
    Last edited by Hack; May 8th, 2006 at 06:10 AM. Reason: Added [RESOLVED] to thread title and green "resolved" checkmark

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Problem moving listbox horizontal lisbox scroller to the right

    By default the VB Listbox does not od Horizontal scrolling. You need to set the Columns property greater than 1 - but then Vertical scrolling is not supported.

    Anyways, to get Horizontal and Vertical scrolling set the "Horizontal Extent" (aka Right Margin) of the ListBox (default is the Width of the control).

    VB Code:
    1. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    2.  
    3. Private Const LB_SETHORIZONTALEXTENT = &H194
    4. 'set the right margin to 3 times the width of the control
    5. SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, ScaleX(List1.Width * 3, Me.ScaleMode, vbPixels), 0
    You can then use the ShowScrollBar API.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Problem moving listbox horizontal lisbox scroller to the right

    Thank u for u reply.
    I want to go with non api method and i can not find the place to changes u mentioned .I can not find horizontal extent!!


    Horizontal and Vertical scrolling set the "Horizontal Extent" (aka Right Margin) of the ListBox (default is the Width of the control).

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Problem moving listbox horizontal lisbox scroller to the right

    You cannot change the Horizontal Extent on a VB ListBox without using the API method.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Problem moving listbox horizontal lisbox scroller to the right

    Quote Originally Posted by brucevde
    You cannot change the Horizontal Extent on a VB ListBox without using the API method.
    I put your code in the top of my project and i get this error:

    Code:
    Compile error
    Invalid outside procedure!
    
    and pointing at bold part

    Code:
    SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, ScaleX(List1.Width * 3, Me.ScaleMode, vbPixels), 0

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Problem moving listbox horizontal lisbox scroller to the right

    That line is a statement and needs to be put into a procedure, like Form_Load

    VB Code:
    1. 'in a form that contains a listbox called List1
    2. Option Explicit
    3.  
    4. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    5. Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, _
    6. ByVal bShow As Long) As Long
    7.  
    8. Private Const SB_HORIZONTAL = 0
    9. Private Const LB_SETHORIZONTALEXTENT = &H194
    10.  
    11. Private Sub Form_Load()
    12.     List1.AddItem "set the right margin to 3 times the width of the control"
    13.    
    14.     SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, ScaleX(List1.Width * 3, Me.ScaleMode, vbPixels), 0
    15.     ShowScrollBar List1.hwnd, SB_HORIZONTAL, 1
    16.  
    17. End Sub

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Problem moving listbox horizontal lisbox scroller to the right

    I get this error now :

    Code:
    Compile error:
    
    Ambiguouse naem detected :ShowScrollBar
    pointing at this line :


    VB Code:
    1. Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, _
    2. ByVal bShow As Long) As Long

  8. #8
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Problem moving listbox horizontal lisbox scroller to the right

    You have 2 functions and/or procedures called ShowScrollBar in the same module.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Problem moving listbox horizontal lisbox scroller to the right

    Quote Originally Posted by brucevde
    You have 2 functions and/or procedures called ShowScrollBar in the same module.
    thanks man it worked. Now i can move the horizantal scroll bar to the right easily:-))

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