Thread: Combobox and Listbox control questions

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    596

    Combobox and Listbox control questions

    I have a couple programs which have a fairly large number (currenty about 35, possible up to about 50) of parameters that can be selected using combobox controls. I am currently using the combobox with dropdownlist style; I want to restrict selections to those in the list and prohibit editing.

    I would like to keep all the controls present in a single dialog (a control panel), but the controls seem to be unecessarily large for the font I am using - Tahoma size 8.

    The problem is that the text in the combobox selection field is positioned lower than it needs to be, and the field has to be extra large to avoid clipping off the character desenders. For example, if I place the same selection text in a listbox, sized to hold only the selection, I can make it significantly smaller than the combobox selection field.

    This alone (using a listbox just for the selection) would work well for displaying all the parameter values in a small control panel, but then I would still need a selection list box of some type to select parameters from. I tried opening up a separate listbox containing the selections, but I cannot find a way to keep the listbox on top of all the other controls. The list appears on top of some of the other controls, but is obscured by others. Also, the listbox cannot extend out beyond the border of the dialog; it becomes clipped at the border. In contrast, the dropdown lists for comboboxes are always on top and can extend beyond the dialog border as needed.

    1) Is there some way to use listboxes to provide the same functionality as a dropdownlist combobox?

    2) As I am currently using dropdownlist style comboboxes, is there any way to remove the highlight that occurs on the selection when an item is selected? (CB_SETEDITSEL does not work on dropdownlist style)

    3) Is the ownerdraw style a feasible way to draw a large number of controls, each with possibly differing lists?

    -
    Last edited by megafiddle; 05-04-2016 at 07:46 PM.

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    596
    A new question.

    I did some experimenting.

    If I create a combobox with a NOT WS_VISIBLE style, I can open and close the dropdown list using the CB_SHOWDROPDOWN message. The edit box portion of the combobox remains hidden. This is important as I would like to use a separate control to display the selection. Also important, the open list box appears to behave just like a list box that is opened with the dropdown arrow icon in a combobox control. I can select from the list, I receive the CBN_SELCHANGE notification along with the selection index, and the list automatically closes. The list also always appears on top like a normally opened combobox list.

    This would be ideal for my use if this behavior is reliable. I think this may be the case for a couple reasons. The CB_SHOWDROPDOWN message controls the show or hide state of the list box. That message has no effect on the edit box portion when the combobox is visible, and so it seems likely that the message should have no effect on the edit box if the combobox is hidden. Also, the COMBOBOXINFO structure contains two handles, one for the edit box, and one for the list box. So the combobox does seem to be a combination of two separate and somewhat independant but coordinated controls, an edit box and a list box.

    My question is a general one, but it also applies to the above as a specific example:

    If something seems like it should work based on the information available, and it does work in trial, how safe is it to assume that it will be reliable?

    Also, I am still interested in any answer to question 2) in my original post, regarding removal of the highlight. I do use comboboxes in the normal fashion also.

    -

  3. #3
    Registered User
    Join Date
    Dec 2010
    Location
    Trinidad, CO (log cabin in middle of nowhere)
    Posts
    148
    Not sure if this will help, but in cases where there are more controls than can easily fit within the surface area of a reasonably sized dialog/form/window, one can subset them in some logical way if possible, and put several within individual tabs of a tab control. Alternately, one can create a scrollable form, where what one is scrolling isn't text, but rather controls, e.g., in your case combo boxes or list boxes. I have done this in Windows CE programs I have written where the screen size is like three or four inches. Works well.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    596
    Thanks

    I think I will use tabs if I run out of room. The parameters being controlled do lend themselves to being placed in separate groups.

    If I can determine whether or not my "custom" control (described above) is reliable, that will save considerable space.

    -

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions about win32 control
    By joltios in forum Windows Programming
    Replies: 3
    Last Post: 01-10-2006, 06:08 AM
  2. Couple Questions, Editbox, ComboBox
    By Zeusbwr in forum Windows Programming
    Replies: 2
    Last Post: 04-12-2005, 05:38 AM
  3. Listbox control gridlines?
    By Devil Panther in forum Windows Programming
    Replies: 2
    Last Post: 12-08-2004, 03:43 PM
  4. A special listbox control...
    By Devil Panther in forum Windows Programming
    Replies: 4
    Last Post: 05-30-2003, 08:24 PM
  5. Listbox control with horizontal scrollbar
    By Ward in forum Windows Programming
    Replies: 1
    Last Post: 02-06-2002, 10:35 AM

Tags for this Thread