Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

How to initialize a dialog box in a Fortran .dll file

lyricx
Beginner
636 Views
In main program, I called a subroutine in a Fortran .dll file to initialize a dialog box, but the initialization failed:

StartDlg = DlgInit(IDD_DIALOG5, XDlg)

How to settle this problem?






0 Kudos
3 Replies
anthonyrichards
New Contributor III
636 Views

That's because you have to use DLGINITFRONRESOURCEHANDLE when the dialog is in a DLL. If your dll is called 'mydll.dll', use

INTEGER Hinst, iret
type (dialog) dlg

Hinst=GetModuleHandle('mydll.dll'C)
iret=DlgInitwithResoureHandle(IDD_DIALOG,Hinst, dlg)

From the Help:

"DLGINIT, DLGINITWITHRESOURCEHANDLE

Run-Time Functions: Initialize a dialog box.

Module: USE DFLOGM

Syntax

result = DLGINIT (id, dlg)
result = DLGINITWITHRESOURCEHANDLE (id, hinst, dlg)


id
(Input) INTEGER(4). Dialog identifier. Can be either the symbolic name for the dialog or the identifier number, both listed in the Include file (with extension .FD).


dlg
(Output) Derived type DIALOG. Contains dialog box parameters.


hinst
(Input) INTEGER(4). Module instance handle in which the dialog resource can be found.

Results:

The result is of type LOGICAL(4). The result is .TRUE. if successful; otherwise, the result is .FALSE..

DLGINIT must be called to initialize a dialog box before it can be used with DLGMODAL, DLGMODELESS, or any other dialog function.

DLGINIT will only search for the dialog box resource in the main application. For example, it will not find a dialog box resource that has been built into a dynamic link library.

DLGINITWITHRESOURCEHANDLE can be used when the dialog resource is not in the main application. If the dialog resource is in a dynamic link library (DLL), hinst must be the value passed as the first argument to the DLLMAIN procedure"

0 Kudos
lyricx
Beginner
636 Views
I used this method to initialize the dialog in my .dll file, but the initialization still failed. Confused!
0 Kudos
anthonyrichards
New Contributor III
636 Views
If you want help, you must post your initialisation code. You should also look at the handle returned by GetModuleHandle to see if it is non-null. When generating the DLL containing your dialog(s), you must also INCLUDE 'RESOURCE.FD' which the resource compiler generates to containthe definitions of your dialog box identifiers (IDD_DIALOG1, etc.) as PARAMETERS.
0 Kudos
Reply