|
-
May 7th, 2006, 12:52 AM
#1
Thread Starter
Frenzied Member
[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:
Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, _
ByVal bShow As Long) As Long
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
-
May 7th, 2006, 01:28 AM
#2
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:
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
Private Const LB_SETHORIZONTALEXTENT = &H194
'set the right margin to 3 times the width of the control
SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, ScaleX(List1.Width * 3, Me.ScaleMode, vbPixels), 0
You can then use the ShowScrollBar API.
-
May 7th, 2006, 01:34 AM
#3
Thread Starter
Frenzied Member
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).
-
May 7th, 2006, 10:37 AM
#4
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.
-
May 7th, 2006, 10:51 AM
#5
Thread Starter
Frenzied Member
Re: Problem moving listbox horizontal lisbox scroller to the right
 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
-
May 7th, 2006, 12:35 PM
#6
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:
'in a form that contains a listbox called List1
Option Explicit
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
Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, _
ByVal bShow As Long) As Long
Private Const SB_HORIZONTAL = 0
Private Const LB_SETHORIZONTALEXTENT = &H194
Private Sub Form_Load()
List1.AddItem "set the right margin to 3 times the width of the control"
SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, ScaleX(List1.Width * 3, Me.ScaleMode, vbPixels), 0
ShowScrollBar List1.hwnd, SB_HORIZONTAL, 1
End Sub
-
May 7th, 2006, 12:40 PM
#7
Thread Starter
Frenzied Member
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:
Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, _
ByVal bShow As Long) As Long
-
May 7th, 2006, 12:46 PM
#8
Re: Problem moving listbox horizontal lisbox scroller to the right
You have 2 functions and/or procedures called ShowScrollBar in the same module.
-
May 7th, 2006, 12:58 PM
#9
Thread Starter
Frenzied Member
Re: Problem moving listbox horizontal lisbox scroller to the right
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|