Re: CListBox horizontal scroll
GetTextExtent is the way to calculate width of a string with a specific
font.
//get a DC
CDC *pDC = GetDC();
//select the listbox font into the dc
CFont *pOldFont = pDC->SelectObject(GetFont());
//calculate the extent
CSize size = pDC->GetTextExtent(Text);
//set everything back and release the dc.
pDC->SelectObject(pOldFont);
ReleaseDC(pDC);
AliR.
"Guido Franzke" <guidof73@yahoo.de> wrote in message
news:exP56gPdKHA.5568@TK2MSFTNGP02.phx.gbl...
Ok I find SetHorizontalExtent:
if (maxwidth < str.GetLength()) maxwidth=str.GetLength();
...
m_lstBox.SetHorizontalExtent(maxwidth*8);
The function wants pixels. So with Arial font, the maxwidth is too big. Is
there an easy way to calculate the width in pixel?
Thanks,
Guido
"Guido Franzke" <guidof73@yahoo.de> schrieb im Newsbeitrag
news:ODUKOFPdKHA.1648@TK2MSFTNGP05.phx.gbl...
Hello NG,
I have a normal CListBox in my dialog. I insert text with AddString. The
string is longer than the area to show the listbox. But I cannot
horizontal
scroll the text.
I changed the properties: horizontal scrollbar = true, vertical scrollbar
=
true, deactivate no scrolling = true.
But I cannot horizontal scroll.
I use MSVC Developer 2003, Version 7.1.3088 and Windows XP.
Can you help me?
Thanks,
Guido