Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Oct 30, 1999

Hide and Show a control's scrollbars

Most VB controls don't let you determine whether they should display a scrollbar or not. For example, a VB ListBox control displays a vertical scrollbar only when the number of its items is larger than the number of visible items. If you want to directly control individual scrollbars, you can use the following two API functions:

Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, _
    ByVal wBar As Long, ByVal bShow As Long) As Long
Private Const SB_HORZ = 0
Private Const SB_VERT = 1
Private Const SB_BOTH = 3
For example, you can display the vertical scrollbar of a ListBox control, even if the ListBox doesn't contain any item, using this code:

ShowScrollBar List1.hWnd, SB_VERT, True
This trick works with several other controls, e.g. ComboBox and TreeView controls, but not all. For example, while you can add a scrollbar to a ListView control, as soon as VB redraws the control (for example, after adding an item), the original settings are restored.
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date