Can Listbox be made to horiz scroll ? 
Author Message
 Can Listbox be made to horiz scroll ?

Is there any way to make a listbox horizontally scroll?

Thanks
Lance



Fri, 04 Oct 2002 03:00:00 GMT  
 Can Listbox be made to horiz scroll ?
Create the listbox with WS_HSCROLL style.

Cheers
Check Abdoul
-----------------


Quote:
> Is there any way to make a listbox horizontally scroll?

> Thanks
> Lance




Fri, 04 Oct 2002 03:00:00 GMT  
 Can Listbox be made to horiz scroll ?
In addition, you have to LB_SETHORIZONTALEXTENT
(CListBox::SetHorizontalExtent) to activate the scrollbar.

To do this, I usually subclass the CListbox, and override
AddString, InsertString, DeleteString, and ResetContent. The subclass
has a variable "width" which is the current width of the longest line
in the listbox. The overrides do the following:

AddString, InsertString: computes the width of the string being added
and makes sure 'width' is at least that value. If the new value is
wider than the previous value, call
CListBox::SetHorizontalExtent(width);

ResetContent: sets the 'width' variable to 0 and does
CListBox::SetHorizontalExtent(0);

DeleteString: deletes the sting by calling CListBox::DeleteString,
then does
     CClientDC dc(this);
     width = 0;
     for(int i = 0; i < CListBox::GetCount(); i++)
        {
         CString s;
         CListBox::GetText(i, s);
         width = max(width, dc.GetTextExtent(s).cx);
        }
   CListBox::SetHorizontalExtent(width);

(Note: you could also override SetHorizontalExtent to set 'width', but
in this model, you'd never need to do actually set it by a client of
the class.

                        joe

On Mon, 17 Apr 2000 14:42:05 -0400, "Check Abdoul"

Quote:

>Create the listbox with WS_HSCROLL style.

>Cheers
>Check Abdoul
>-----------------



>> Is there any way to make a listbox horizontally scroll?

>> Thanks
>> Lance


Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Fri, 04 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Automatic horiz scroll in listbox

2. Listbox with no Horiz Scroll

3. Automatic horiz scroll in listbox

4. help:combo box tooltip/horiz scroll

5. CListCtrl, horiz scrolling, and headers

6. Scrolling listbox headings and listbox together

7. Listbox without scroll?

8. synchronizing scroll of two listboxes

9. dual listbox scroll

10. Listbox not auto horizontal scroll on AddString, Why ?

11. Delete first line of MultiLineEdit/ListBox and scroll up

12. Listbox scrolls

 

 
Powered by phpBB® Forum Software