Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

combo box

mnering
Beginner
969 Views
I'm trying to use a combo box with the following code:

lret = DlgSet(gdlg, IDC_Contract_COMBO, 2, DLG_NumItems)
lret = DlgSet(gdlg, IDC_Contract_COMBO, "MEAf0203", 1)
lret = DlgSet(gdlg, IDC_Contract_COMBO, "NH0102", 2)

When I run the program there is nothing listed in the combo box. Any thoughts?

Mike
0 Kudos
11 Replies
Jugoslav_Dujic
Valued Contributor II
969 Views
Well, several thoughts...
- you misspelled combo ID
- you forgot to INCLUDE "Resource.fd"
- what's the value of lret?
0 Kudos
mnering
Beginner
969 Views
Things are spelled correcly I think, otherwise I couldn't have compiled. Also, included resouce.fd is a few lines up, and is also necessary to compile.

But, lret is .false.

0 Kudos
Jugoslav_Dujic
Valued Contributor II
969 Views
The only errors that come on my mind are stupid, like not calling DlgInit for the dialog -- hey, did you check the success of DlgInit? Does DlgSet work for other controls?
0 Kudos
mnering
Beginner
969 Views
Yeah ... everything else checks out. DlgInit is .true. for the Dialog, and other DlgSets are coming back as .true. The combo box does show up when I execute .. it's just blank.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
969 Views
It looks as if you'll have to step in into DlgSet to see why it fails -- if it won't step in from the debugger, try including DFLOGM.f90 from .../DF98/Include. I'm out of ideas (and the ones so far weren't very bright :-D).
0 Kudos
mnering
Beginner
969 Views
In stepping through DlgSet it seems to get kicked out under the "ingnore unsupported controls" portion of the routine.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
969 Views
Take a look at the source of .rc file -- it's probably a COMBOBOXEX (the last on the resource palette). If I'm right, delete it & insert an ordinary combo box.
0 Kudos
Intel_C_Intel
Employee
969 Views
I have had the same problem with combo box and it took me several days and much frustration to solve. First, look at the sample program CELSICON where you are going to find an undocumented feature and a little subroutine called DoCallBackInit to set callback for WM_INITDIALOG, which is needed just for combo box. I found this one myself. But the combo box showed only one item at run time. This one was a design time difficulty which I couldn't solve without help from vf-support. You need to set the size of the dropdown list. One merely clicks on the window and moves the edges with the mouse. But the dropdown list window will not show at design time unless you click on the down arrow on the right side of the current selection window. Once you see the dropdown list window, you can size it with the mouse just like the current selection window. Easy, only if I knew it!

Sabalan.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
969 Views
Sabalan,
DoCallBackInit is undocumented for a good reason -- there's standard way to do it:
 DlgSetSub(Dlg, IDD_DIALOG1, OnDialogInit). 
Why is it needed only for combo box? Combo boxes used to work normally (I don't have time right now to test it). It is required for tab control to work only AFAIK. I agree that the trick with sizing of dropdown list is tricky to deduce indeed (albeit documented somewhere in depth of rc help).

Jugoslav
0 Kudos
Intel_C_Intel
Employee
969 Views
I don't know Yugoslav. I just followed "Using list boxes and combo boxes" in the on-line help, and the combo box did not work, as it didn't for Mike either. Then I searched in samples and found out what I wrote here. The comment about "undocumented feature" is cited directly from the sample code CELSICON. It is a DlgSetSub as you write but in the subroutine DoCallBackInit, which is called instead of your OnDialogInit, there is a SetDlgItemText which I couldn't find anywhere in the on-line help.

Sabalan.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
969 Views
First, sorry, I misread your statement -- I thought DoCallBackInit was an undocumented routine from DFLOGM.f90; actually, it was a routine from CelsIcon.

That DlgSetSub feature for WM_INITDIALOG is definitely documented now (see DlgSetSub). I'd guess that it wasn't documented earlier, at the time when CelsIcon was written. Maybe it was accompanied with a bug in combo box handling (DLG_STATE in code below); SetDlgItemText is a Win32 API routine. I'm just guessing.

I've just assembled a simple test program and it worked just fine on CVF6.6:
PROGRAM ComboTest

USE DFLOGM

IMPLICIT NONE

INCLUDE "Resource.fd"

TYPE(Dialog):: Dlg
INTEGER::      iSt

iSt = DlgInit(IDD_DIALOG1, Dlg)
iSt = DlgSet(Dlg, IDC_COMBO1, 2, DLG_NUMITEMS)
iSt = DlgSet(Dlg, IDC_COMBO1, "AAA", 1)
iSt = DlgSet(Dlg, IDC_COMBO1, "BBB", 2)
iSt = DlgSet(Dlg, IDC_COMBO1, "CCC", DLG_STATE)
iSt = DlgModal(Dlg)

END PROGRAM ComboTest
0 Kudos
Reply