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

Trying to fill combo boxes in QuickWIN

kaffee46
Beginner
796 Views
Hi Guys,

i am new and want first of all say hello.

I am working on a project where i have to use the CVF 6.6 for a QuickWIN Application.

I created a Dialog with a Combo Box(IDC_COMBO1) and three Edit boxes (IDC_EDIT_C, IDC_EDIT_CR, IDC_EDIT_MN).
I put the following datas into the Combo Box Data field (enter list box items..): Type A, Type B, Type C.
If i execute the program i can choose between Type A, Type B, Type C, ^so far so good.
The user should be able to choose between Type A, Type B or Type C.

What i want the program to do is:
If the user chooses "Type A",
the Value of EDIT_IDC_C should be 5
the Value of EDIT_IDC_CR should be 6
the Value of EDIT_IDC_MN should be 7

If the user chooses "Type B",
the Value of EDIT_IDC_C should be 8
the Value of EDIT_IDC_CR should be 9
the Value of EDIT_IDC_MN should be 10

If the user chooses "Type C",
the Value of EDIT_IDC_C should be 11
the Value of EDIT_IDC_CR should be 12
the Value of EDIT_IDC_MN should be 13

This is my actual code (of the subroutine of the dialog box):
subroutine Werkstoff( checked )
USE DFLOGM
LOGICAL, INTENT(IN) :: checked
logical ll, l
integer i
type(dialog) WerkstoffDlg
include 'resource.fd'
l = DlgInit( IDD_Werkstoff, WerkstoffDlg )
i = DlgModal( WerkstoffDlg )
call DlgUninit( WerkstoffDlg )
return; call unusedqq( ll )
end subroutine

Is somebody able to help me with this problem?

Thanks
Marco
0 Kudos
4 Replies
onkelhotte
New Contributor II
796 Views
Hi Marco,

you have to set a callback routine for your controls, for which you want to have interaction, likeButtons, Checkboxes and Comboboxes.

In your example, it should look like this:

[cpp]subroutine Werkstoff( checked ) 
USE DFLOGM
LOGICAL, INTENT(IN) :: checked 
logical ll, l
integer i
type(dialog) WerkstoffDlg
include 'resource.fd'

l = DlgInit( IDD_Werkstoff, WerkstoffDlg )

l=dlgSetSub(WerkstoffDlg,IDC_COMBO1,onDialogButton)

i = DlgModal( WerkstoffDlg )
call DlgUninit( WerkstoffDlg )
return
call unusedqq( ll )
end subroutine

subroutine onDialogButton (dlg,iButton,iType)
implicit none
include 'resource.fd'
integer(kind=4) iButton,iType
character*256 string
logical l
type (dialog) dlg

select case (iButton)
case(IDC_COMBO1)
l=dlgGet(dlg,IDC_COMBO1,string,DLG_STATE)
if(string == 'Type A') then
  dlgSet(dlg,IDC_EDIT_C,'5')
  dlgSet(dlg,IDC_EDIT_CR,'6')
  dlgSet(dlg,IDC_EDIT_MN,'7')
! fill in your other choices...
end if end select return end subroutine onDialogButton [/cpp]

Markus
0 Kudos
Jugoslav_Dujic
Valued Contributor II
796 Views
Quoting - onkelhotte
Hi Marco,
[cpp]select case (iButton)
case(IDC_COMBO1)
l=dlgGet(dlg,IDC_COMBO1,string,DLG_STATE)
if(string == 'Type A') then
dlgSet(dlg,IDC_EDIT_C,'5')
dlgSet(dlg,IDC_EDIT_CR,'6')
dlgSet(dlg,IDC_EDIT_MN,'7')
! fill in your other choices...
end if
end select
return
end subroutine onDialogButton
[/cpp]


That will work, but it's much more elegant to check the selected combo box item position rather than its string:

[cpp]l = DlgGet(Dlg, IDC_COMBO1, iPos, DLG_STATE)
!//We'll use the feature that the edit box contents linearly
!//depend on the combo position, and use internal write:
WRITE(string, "(i2)") 2+3*iPos !//iPos=1 gives 5
l = DlgSet(Dlg, IDC_EDIT_C, string)
WRITE(string, "(i2)") 3+3*iPos
l = DlgSet(Dlg, IDC_EDIT_CR, string)
WRITE(string, "(i2)") 4+3*iPos
l = DlgSet(Dlg, IDC_EDIT_CR, string)
[/cpp]

0 Kudos
kaffee46
Beginner
796 Views
Quoting - Jugoslav Dujic

That will work, but it's much more elegant to check the selected combo box item position rather than its string:

[cpp]l = DlgGet(Dlg, IDC_COMBO1, iPos, DLG_STATE)
!//We'll use the feature that the edit box contents linearly
!//depend on the combo position, and use internal write:
WRITE(string, "(i2)") 2+3*iPos !//iPos=1 gives 5
l = DlgSet(Dlg, IDC_EDIT_C, string)
WRITE(string, "(i2)") 3+3*iPos
l = DlgSet(Dlg, IDC_EDIT_CR, string)
WRITE(string, "(i2)") 4+3*iPos
l = DlgSet(Dlg, IDC_EDIT_CR, string)
[/cpp]


Hi Jugoslav and Onkelhotte,

thank you both very much for your help, it works!
But for your information, i had to change some things in the code:

- i had to add "use dflogm" to the subroutine "onDialogButton", without this it does not work.
- only "dlgSet(dlg,IDC_EDIT_C,'5')" does not work, you need a "l = dlgSet(dlg,IDC_EDIT_C,'5')"
- instead of (dlg,IDC_EDIT_C,'5') i have to use (dlg,IDC_EDIT_C,"5"C), i dont know why, but otherwise it does not work correctly if i go from TypeA to TypeB to TypeC and back again, the values are not transferred correctly.

Thanks again
Marco


0 Kudos
onkelhotte
New Contributor II
796 Views
Quoting - Jugoslav Dujic

That will work, but it's much more elegant to check the selected combo box item position rather than its string:

[cpp]l = DlgGet(Dlg, IDC_COMBO1, iPos, DLG_STATE)
!//We'll use the feature that the edit box contents linearly
!//depend on the combo position, and use internal write:
WRITE(string, "(i2)") 2+3*iPos !//iPos=1 gives 5
l = DlgSet(Dlg, IDC_EDIT_C, string)
WRITE(string, "(i2)") 3+3*iPos
l = DlgSet(Dlg, IDC_EDIT_CR, string)
WRITE(string, "(i2)") 4+3*iPos
l = DlgSet(Dlg, IDC_EDIT_CR, string)
[/cpp]


Jugoslav, I use strings because in my programs the entries of a Combo Box are static and so I can easily see which entry was picked. Working with positions would be possible of course, but not intuitive.

@Marco: I forgot the l=, my fault. You have to add the C after your string because it requires a C string, and C strings have a char(0) as the last character.

Markus
0 Kudos
Reply