Listbox control with horizontal scrollbar
Hi,
I am working with Visual C++ 6.0 and I'm not using MFC.
What I want to accomplish is making a listbox which will contain strings that are larger than the width of the listbox control.
I've create the following listbox in the resource editor:
(I only include the styles that are set ON)
Border, Notify, Horizontal scroll, Vertical scroll, No Integral heigth.
Now if I add large strings (using the LB_ADDSTRING message), the horizontal scrollbar does not appear and I can't see the end of the string.
Can you help me out?
Thanks in advance!
Found it myself! (Thanks anyway)
I found this myself using some information at:
http://support.microsoft.com/default...b;EN-US;q66370
char szSomeString[] = {abcdefghijklmnopqrstuvwxyz...};
int iWidth;
HWND hList = GetDlgItem(hWnd, IDC_LIST_RECORDS);
HDC dcList = GetDC(hList);
RECT rect;
GetClientRect(hList,&rect);
iWidth = rect.right;
HFONT hF = (HFONT)SendMessage(hList,WM_GETFONT,0,0);
HGDIOBJ hOld = SelectObject(dcList,hF);
SIZE sz;
GetTextExtentPoint32(dcList,szSomeString,strlen(sz SomeString),&sz);
sz.cx += 3* GetSystemMetrics(SM_CXBORDER);
if(sz.cx>iWidth)
{
iWidth = sz.cx;
SendMessage(hList,LB_SETHORIZONTALEXTENT,(WPARAM)i Width,0);
}
SelectObject(dcList,hOld);
ReleaseDC(hList,dcList);
Add this code and the horizontal scrollbar works very nice!!!
:D