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

Post-edit trigger for edit box in a dialog box

michael_green
Beginner
319 Views
I need to update the contents of a read-only edit box following the user's input of some value in a different edit box in the same dialog. Can anyone tell me how to do this?

Many thanks
Mike
0 Kudos
7 Replies
Jugoslav_Dujic
Valued Contributor II
319 Views
You should write a DLG_CHANGE callback routine for the non-read-only edit-box; process the data there and do a DlgSet for the read-only box. See DlgSetSub in the docs and CVF samples. (There are currently two threads going on here on similar subjects, "cursor position in editbox after callback" and "Checking a real number is entered in an edit box" ).

Jugoslav
0 Kudos
michael_green
Beginner
319 Views
Thanks very much for your swift reply. I have worked hard at this all day without success - but I'm very new to CVF so that might explain it. I'm converting a large F77 program from VMS to a Win32 API application. I have a dialog, itself run from a callback routine, in which the user enters a number which is then used to calculate a target for another part of the dialog. So I've got:

external CalcTarget
....
select case(message)
case(WM_INITDIALOG)
....
bret = DlgInit(IDD_Thin1,dlg)
bret = DlgSetSub(dlg,IDC_new,CalcTarget) !This returns .true.

call CenterWindow(hDlg,GetWindow(hDlg,GW_OWNER))

call CalcTarget(dlg,IDC_new,DLG_CHANGE) !This works fine as a manual call ...

... but making a change to the edit box, IDC_new, fails to activate CalcTarget.

I have searched the examples but can only find quickwin or dialog based applications, which seem subtly different - at any rate, I am unable to generalise from them to make my application work. Any help would be greatly appreciated.

Many thanks in advance
Mike (in Australia)
0 Kudos
isn-removed200637
319 Views
Have you forgotten to activate the second dialog? (IDD_Thin1) using
!  ACTIVATE THE DIALOG
retint=DLGMODAL(dlg)

Do not forget to release the dialog resources when you have finished, using
!release dialog resources
CALL DLGUNINIT(dlg)

Make sure you save the new dialog's handle ('dlg') safely. Are you using 'dlg' for the dialog that opens the new one as well?
0 Kudos
Jugoslav_Dujic
Valued Contributor II
319 Views
Regarding dialog box handling, the difference between Win32, console and QuickWin application is (should be)zilch. Dialogs are kinda world of its own.

I'm a bit confused about your code -- there appears to be a parent dialog created with DFWIN's CreateDialog/DialogBox, which creates another dialog using DFLOGM's DlgModal/DlgModeless, right? I mean, it's OK, but I wonder why you didn't use the same method consistently?

I can't tell you offhand what's wrong. You can include ...DF98IncludeDFLOGM.f90 folder into your project and debug it. Place a breakpoint in DlgWmCommand routine and type something in the edit box -- it should call DlgDoCallback (you can't debug that one, because it's in library). Does it? What are arguments of DlgDoCallback if it does? Where it exited if it didn't?

Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
319 Views
[Tony's post triggers a lamp in my head]

Michael, is IDD_Thin1 the same dialog that receives that WM_INITDIALOG? If it is, you cannot do it that way, i.e. you cannot "convert" a hDlg obtained from DialogBox/DialogProc into a DIALOG structure (the reverse is possible -- there's Dlg%hWnd member).

You see, DFLOGM is a wrapper around Win32 dialog functions. That means that it is simpler to use but less powerful. When you create a dialog using CreateDialog/DialogBox APIs, forget about using any DFLOGM routines on it. OTOH, if you create the dialog with DlgModal/DlgModeless, you can use most APIs (e.g. when you need extra functionality not provided by DFLOGM) using Dlg%hWnd as a "bridge".

If the assumption from my first paragraph is correct, you can do what you want by handling WM_COMMAND from the first edit control:
case (WM_COMMAND)
   if (loword(wParam)==IDC_new .and. hiword(wParam)==EN_CHANGE) then
      b = GetWindowText(lParam, szText, LEN(szText))
      !Do something with szText. Take care that it's char(0)-
      !terminated so you might want to strip it using INDEX
      ...
      b = SetDlgItemText(hDlg, IDC_readonlyone, something) 
   end if
Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
319 Views
My initial reply probably created the confusion -- I asssumed you were using DFLOGM. Next time I'll ask first :-)
0 Kudos
michael_green
Beginner
319 Views
Hi Guys,
What a team! Thanks very much for the info - Jugoslav's method works very nicely. I'm sorry my original post was less than clear. Only one dialog box is involved here, and it's activated by DialogBoxParam which I gather is equivalent to using DlgModal. The user enters a number in an edit box, and this, coupled with information from elsewhere in the program, is used to calculate a target value in another edit box. It's very pleasing to see it working so well now. Thanks again.

Mike (Perth, Australia)
0 Kudos
Reply