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

Do something after click OK on a Dialog

cean
New Contributor I
272 Views

Hi,

 

On a Dialog, when click OK button, I want to create a file which saves all the setting on that Dialog. I can do it with other kind of Buttons, but not the OK button. What is the function behind OK_Clicked where I could insert my code?

I have read these, but haven't found a clue.

Using Buttons (intel.com)

Setting Return Values and Exiting (intel.com)

 

Cheers,

Cean

 

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
212 Views

I have no idea what tDLG is. Somewhere you call DLGMODAL. This is a function that returns an integer value of the action that caused the dialog to close, so you could check it against IDOK. The About dialog is not the place to do this.

View solution in original post

7 Replies
Steve_Lionel
Black Belt Retired Employee
255 Views

If you are using modal dialog, you can take action when that call returns.  If it's a modeless dialog, then Microsoft's recommendation is that you use a Close menu item or button.

cean
New Contributor I
243 Views
The tutorial says: "DLGMODAL  returns the control name of the control that caused it to exit; for example, IDOK or IDCANCEL".
 
I'll try using modal dialog. How do I get this return value?
 
In my SDI template generated program, I tried to start my test Dialog tDialog with this code. Can't get it working.
case (ID_FILE_TDIALOG)    
        !hDC = GetDC(hwnd)
        call tDLG()
        !ret=tDLG()   !not working
        open (6,file='d:\1.txt')
        write (6,*) ret
        close (6)
        return
In the same section, there is the starting  the About Dialog code:
            case (IDM_ABOUT)
                lpszName = "AboutDlg"C
                ret = DialogBoxParam(ghInstance,LOC(lpszName),hWnd,& 
                  LOC(AboutDlgProc), 0_LONG_PTR)
                MainWndProc = 0
                return

IDOK is checked inside AboutDlgProc.

Is this the way I need to follow?

 

 

 

Steve_Lionel
Black Belt Retired Employee
213 Views

I have no idea what tDLG is. Somewhere you call DLGMODAL. This is a function that returns an integer value of the action that caused the dialog to close, so you could check it against IDOK. The About dialog is not the place to do this.

cean
New Contributor I
183 Views

tDLG is my Dialog.

 

"Somewhere you call DLGMODAL." 

 

This solved my question. Use below code, I can see the return value is different between OK and Cancel.

        iSt = DlgModal(Dlg)
        open (6,file='d:\00file\1.txt')
        write (6,*) iSt
        close (6)

 

 

andrew_4619
Honored Contributor I
165 Views

Yes the return is IDOK or IDCANCEL or a user defined return value.

andrew_4619
Honored Contributor I
209 Views

The OK button is "IDOK" control index so you can process that case in the dlgproc if you want to to some pre-exit activity.

Steve_Lionel
Black Belt Retired Employee
202 Views

I would advise against doing anything time-consuming in a dlgproc. You could set a flag or store some info that can be used once the dialog box exits.

Reply