Moving just one part of listbox

This is a discussion on Moving just one part of listbox within the Windows Programming forums, part of the Platform Specific Boards category; I have programmed a listbox onto the client area. In CreateWindowEx I have set where the list box should be ...

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Moving just one part of listbox

    I have programmed a listbox onto the client area. In CreateWindowEx I have set where the list box should be placed on the client and how wide at creation time. But, when the user does something to enter a string, I want to make the listbox accomidate (sp?) to fit another string by making it cyChar longer. I know that I would use MoveWindow to do this sort of thing, but I don't want to fool around with the other three values of the placement/size of the listbox. Is there an easier way to just make the listbox longer without as much risk?

    Garfield
    1978 Silver Anniversary Corvette

  2. #2
    Unregistered
    Guest
    What's wrong with MoveWindow? All you need do is store the coords of your listbox - just change those variables and feed them into MoveWindow as required. So if width is all you need change then, for example (pseudo-code):

    nListBoxWidth=nNewListBoxWidth;
    MoveWindow(hwndListBox,Left,Top,nListBoxWidth,Heig ht,1);

    ...or longer...but i'm sure you get the idea.

    Or...

    You could just give the listbox the WS_VSCROLL style, ie give it a vertical scrollbar, instead and let it deal with accomodating your expanding list.

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> You could just give the listbox the WS_VSCROLL style, ie give it a vertical scrollbar, instead and let it deal with accomodating your expanding list. <<

    Yeah, I'll probably just do this. I had this in the back of my mind, but I wanted to see if I couldn't just expand the listbox with everystring.

    Another question...

    Would it be the combo box child that is a "drop-down listbox"? Or just another window type of the listbox? That could also be another way for me to do this. Thanks......

    Garfield
    1978 Silver Anniversary Corvette

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Another way is to scroll it up each time a string is entered. The style is 'show selection always'.

    or dynamically

    Code:
    	SendMessage(hListBox, LVM_GETITEMRECT, (WPARAM)(int)iRow, (LPARAM)(LPRECT) &ItemRect);
    	SendMessage(hListBox, LVM_SCROLL, (WPARAM)0, (LPARAM) (ItemRect.bottom-ItemRect.top));
    	SendMessage(hListBox, LVM_ENSUREVISIBLE, (WPARAM)iRow, (LPARAM)FALSE);
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    Code:
    SetWindowPos(listBox, 0, 0, 0, newWidth, newHeight, SWP_NOZORDER | SWP_NOMOVE);
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

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. ListBox Extra Data Storage
    By Welder in forum Windows Programming
    Replies: 1
    Last Post: 11-01-2007, 01:46 PM
  3. Replies: 4
    Last Post: 01-16-2006, 04:58 PM
  4. Suspicious Pointer Conversion
    By mr_spanky202 in forum C Programming
    Replies: 35
    Last Post: 04-11-2003, 12:35 PM
  5. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 07:28 AM

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