Resize listbox

This is a discussion on Resize listbox within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to get a header control to work with some listboxes so when the user drags a header, the ...

  1. #1
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972

    Resize listbox

    I'm trying to get a header control to work with some listboxes so when the user drags a header, the listboxes (each listbox is supposed to be a column) are resized to match up with the header. So when I receive the HDN_TRACK message this is what I do:
    Code:
         case HDN_TRACK:
            NMHEADER* nmh = (LPNMHEADER)lParam;
            RECT rc;
            GetWindowRect(GetDlgItem(hwnd,IDC_LIST1),&rc);
            SendMessage(GetDlgItem(hwnd,IDC_LIST1),WM_SIZE,SIZE_RESTORED,MAKELPARAM(nmh->pitem->cxy,rc.bottom-rc.top));
          break;
    But for some reason, no matter what lparam is in the call to SendMessage, the listbox doesn't change size.

    If it helps, here's the declaration of the listbox in the resource script (generated by VS):
    Code:
        LISTBOX         IDC_LIST1,0,32,300,155,LBS_SORT | LBS_NOINTEGRALHEIGHT | 
                        NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Ah forget it, I used SetWindowPos instead and that seems to work fine...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You can also use MoveWindow. May I suggest a list-view?

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    That sounds a lot easier, thanks!
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 07:53 PM
  2. png Image Resize
    By bhupesh.kec in forum C Programming
    Replies: 3
    Last Post: 12-06-2007, 07:52 AM
  3. ListBox Extra Data Storage
    By Welder in forum Windows Programming
    Replies: 1
    Last Post: 11-01-2007, 02:46 PM
  4. How to cast a ListBox item to an int for a switch statment?
    By Swaine777 in forum C++ Programming
    Replies: 8
    Last Post: 09-26-2004, 09:52 PM
  5. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 08:28 AM

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