C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-06-2002, 09:03 AM   #1
Registered User
 
Ward's Avatar
 
Join Date: Sep 2001
Location: Belgium
Posts: 39
Question 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!
__________________
Greetings.
Ward is offline   Reply With Quote
Old 02-06-2002, 10:35 AM   #2
Registered User
 
Ward's Avatar
 
Join Date: Sep 2001
Location: Belgium
Posts: 39
Lightbulb 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!!!
__________________
Greetings.
Ward is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:47 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22