![]() |
| | #1 |
| Registered User Join Date: Sep 2001 Location: Belgium
Posts: 39
| 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!
__________________ Greetings. |
| Ward is offline | |
| | #2 |
| Registered User Join Date: Sep 2001 Location: Belgium
Posts: 39
| 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!!!
__________________ Greetings. |
| Ward is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| horizontal scrollbar in listbox | umen242 | Windows Programming | 3 | 06-30-2009 08:40 AM |
| Button handler | Nephiroth | Windows Programming | 8 | 03-12-2006 06:23 AM |
| How to active the scrollbar on ListBox manually ? | ralph23 | C++ Programming | 2 | 03-10-2006 09:29 PM |
| CTreeCtrl horizontal scrollbar | eXistenZ | C++ Programming | 0 | 08-21-2005 11:35 AM |
| Tab Controls - API | -KEN- | Windows Programming | 7 | 06-02-2002 09:44 AM |