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

IVF: Handle to modal dialog zero?

alb_f
Novice
647 Views

For some test work (using VS and IVF) I created a single modal dialog like

use IFLOGM
lret = DLGINIT(IDD_DIALOG, dlg)
iret = DLGMODAL(dlg)

It works fine but I noticed that the dialog handle dlg%hWnd is 0 after DLGINIT().

Why is that? And the more important question: is there a way to obtain a handle to it?

This because I need the handle to it for some controls I want to test.

From searching the internet I only found it is 0, but not why.. Is it because it has no parent dialog?

 

 

 

0 Kudos
6 Replies
Steve_Lionel
Honored Contributor III
635 Views

I would not expect the handle to be nonzero after just calling DLGINIT, as the window for the dialog hasn't been created yet - that is done in the DLGMODAL call. As best as I can tell, the creation of the dialog window is done internally to the support library - some of the IFLOGM code is in module procedures in iflogm.f90, but not all of it. I guess the idea is that the user doesn't need to know the dialog window handle?  I wonder (haven't tried this) if you called GetForegroundWIndow from a callback if you'd get anything useful.

0 Kudos
alb_f
Novice
613 Views

Thanks for your answer, indeed there is some logic in making it available for the user at the moment it could be needed like during a callback from an event but that's for "normal" users..

I found a way out of this issue by using CreateDialogParam() instead of DlgModal() but this leads to more work creating and destroying the dialogs with their own routines. I like to use just the standard DlgModal if possible but since the DlgModal call blocks any further code after it, the handle should be available before this call. I'll try some calls like the one you propose.

(forgot to mention). Actually this is cheating, the CreateDialogParam call creates a modeless dialog, not a modal one. Perhaps I should try to move to modeless dialogs instead.

0 Kudos
andrew_4619
Honored Contributor II
608 Views

It always used to set the handle as the first item in the dlg structure..... Did you try a test build of the intel dialog sample program to see that that does?

0 Kudos
Steve_Lionel
Honored Contributor III
584 Views

I did a test, and you can see the actual code in iflogm.f90. The handle component is set to zero in DLGINIT and isn't changed in DLGMODAL. It might get changed internally to the library but put back before DLGMODAL returns.

0 Kudos
mfinnis
New Contributor II
600 Views

You need to set a callback routine with DlgSetSub for the dialog. This is called with a callbacktype of DLG_INIT after the window is created but before it is displayed, ie dlg%hwnd contains the window handle. All the code you need to implement the dialog can be included in, or referenced by, the callback routine(s).

alb_f
Novice
580 Views

This is my current solution also after various other trials. Read somewhere that via the DLG_INIT you have the dialog just before it is displayed and indeed, there the handle is assigned already. So that saves my day.  Now I can use both modal and modeless dialogs with fancy bitmaps and coloured controls. Thanks for the discussion and ideas!

0 Kudos
Reply