Listbox control with horizontal scrollbar

This is a discussion on Listbox control with horizontal scrollbar within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I am working with Visual C++ 6.0 and I'm not using MFC. What I want to accomplish is making ...

  1. #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.

  2. #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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. horizontal scrollbar in listbox
    By umen242 in forum Windows Programming
    Replies: 4
    Last Post: 09-17-2010, 01:20 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  3. How to active the scrollbar on ListBox manually ?
    By ralph23 in forum C++ Programming
    Replies: 2
    Last Post: 03-10-2006, 08:29 PM
  4. CTreeCtrl horizontal scrollbar
    By eXistenZ in forum C++ Programming
    Replies: 0
    Last Post: 08-21-2005, 11:35 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

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