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?
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.
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.
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?
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).
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.