-
February 23rd, 2006, 05:00 AM
#1
How add a horizontal scrollbar in ListBox?
I need to add a Horizontal Scrollbar in a List box.
How do that?
Thanks
-
February 23rd, 2006, 05:28 AM
#2
Re: How add a horizontal scrollbar in ListBox?
Right click on the control, select properties and under the styles tab, select horizontal scroll
Regards
I don't mind that you think slowly but I do mind that you are publishing faster than you think. Wolfgang Pauli, physicist, Nobel laureate (1900-1958)
-
February 23rd, 2006, 06:09 AM
#3
Re: How add a horizontal scrollbar in ListBox?
OR:
You can use the SendMessage API function to add a horizontal scroll bar dynamically to a list box using the LB_SETHORIZONTALEXTENT message.
It takes seconds for rating…that actually compensates the minutes taken for giving answers
The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
Regards, Be generous->Rate people
Jayender!!
-
February 23rd, 2006, 06:26 AM
#4
Re: How add a horizontal scrollbar in ListBox?
Thanks at all. I find and solved my problem with this code....
// Find the longest string in the list box.
CListBox* pmyListBox = (CListBox *)GetDlgItem(IDC_LIST1);
CString str;
CSize sz;
int dx = 0;
TEXTMETRIC tm;
CDC* pDC = pmyListBox->GetDC();
CFont* pFont = pmyListBox->GetFont();
// Select the listbox font, save the old font
CFont* pOldFont = pDC->SelectObject(pFont);
// Get the text metrics for avg char width
pDC->GetTextMetrics(&tm);
for (i = 0; i < pmyListBox->GetCount(); i++)
{
pmyListBox->GetText(i, str);
sz = pDC->GetTextExtent(str);
// Add the avg width to prevent clipping
sz.cx += tm.tmAveCharWidth;
if (sz.cx > dx)
dx = sz.cx;
}
// Select the old font back into the DC
pDC->SelectObject(pOldFont);
pmyListBox->ReleaseDC(pDC);
// Set the horizontal extent so every character of all strings
// can be scrolled to.
pmyListBox->SetHorizontalExtent(dx);
-
February 23rd, 2006, 06:49 AM
#5
Re: How add a horizontal scrollbar in ListBox?
Originally Posted by Antonio2929
Thanks at all. I find and solved my problem with this code....
// Set the horizontal extent so every character of all strings
// can be scrolled to.
pmyListBox->SetHorizontalExtent(dx);
You are welcome dude.. and please use : Code tags
It takes seconds for rating…that actually compensates the minutes taken for giving answers
The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
Regards, Be generous->Rate people
Jayender!!
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
|