Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wanting to "hybridize" the standard ComboBox as a control; any ideas?

Status
Not open for further replies.

TommyCee

Civil/Environmental
Nov 6, 2009
13
US
This is for Compaq Visual Fortran (v6x):

As most of you know, for the standard ComboBox has 3 Types (modes):

1. Simple
2. Dropdown
3. Drop List

1&2 are both editable and only differ in the way the choices are displayed (simple exposes all choices; Dropdown hides them until the dropdown list is clicked).

In this latter sense (display of choices), 2&3 are identical but the choices for 3 are fixed (i.e., not editable).

In my case, I have an input variable that takes on one of two modes in terms of choices:
A) a fixed value (hardwired; user cannot alter).
B) some editable (adjustable) value - presented in an edit box that the user can change.

For A, #3 (Drop List) would be ideal; for B, #2 (Dropdown) would be ideal.

This is actually very common in dialogs you see used in a variety of apps. in which a list may provide a series of "fixed" choices, and then a last one [e.g., Other (please specify)] - the "please specify" is editable. I believe Delphi allows one to configure this way fairly easily.

For CVF, I wonder if there is any way to configure either the ComboBox in the Resource Editor itself, or some trick coding using (for example) DlgSet, etc. to accomplish this.

Any help is appreciated.

p.s.
The so-called "Extended" ComboBox in the Resource Editor is of no help in overcoming this obstacle.
 
Replies continue below

Recommended for you

The only way I know of is to overlay another editable window which is the same size as the combo box on top of the combo box. When the user presses return, the new option is added to the combo box.

The overlaid box is quite painful to program and debug. You also need to close it immediately you lose focus otherwise it gets left behind when the dialog moves.

Easiest to use 2 machines to debug this - once you lose focus and go into the debugger, strange things happen.
 
Thanks XWB. Your "solution" seems a bit complicated (as you admitted) and tenuous. Here's a response I got on an IVF forum; what do you think?

I would say that you want to set up an unsorted list in your ComboBox, with the editable entry's location permanently set so that when you select a list item whose index does not match the editable entry's index, you can disable the edit box selection so that it cannot be edited. You can get the handle to the edit control portion of a ComboBoxEx control by sending it the CBEM_GetEditControl message with parameters wParam = 0, lParam = 0 using the Windows API function SendMessage, using the handle to the ComboBox.
e.g.

use dfWinTY ! contains definitions of window messages such as CBEM_GetEditControl
Integer(handle) hEditControl, hComboWnd
hEditControl= SendMessage(hComboWnd, & handle of combo box
CBEM_GetEditControl, & message to send
0, & first message parameter
0 & second message parameter)


This is consistent with the description for CBEM_GetEditControl Message posted here:
 
That would work but like my method, you have to monitor when it goes out of focus and EnableWindow TRUE or FALSE accordingly.

Basically, you need to be as warped as your users and handle all the weird stuff they will do like typing half way and then changing their mind and going back to the drop down list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top