Visible to Intel only — GUID: GUID-09DBA700-97B6-4404-8003-D411ACC28E5D
Visible to Intel only — GUID: GUID-09DBA700-97B6-4404-8003-D411ACC28E5D
Using Dialog Controls in a DLL
You can use a dialog box that is defined in a DLL. To do so, you must inform the dialog routines that the dialog resource is located in the DLL, rather than in the main application. The dialog routines will look for the dialog resource in the main application by default.
To do this, initialize your dialog box using DlgInitWithResourceHandleDlgInit rather than DlgInit . As compared to DlgInit, DlgInitWithResourceHandle takes an additional argument named "hinst". The "hinst" argument is the module instance handle in which the dialog resource can be found. For a DLL, this handle is passed into the DLL entry point, DllMain.
An example of a DllMain function follows:
module dll_globals integer ghInst ! DLL instance handle end module dll_globals !******************************************************************** !* FUNCTION: DllMain(HANDLE, DWORD, LPVOID) !* !* PURPOSE: DllMain is called by Windows when !* the DLL is initialized, Thread Attached, and other times. !* Refer to SDK documentation, as to the different ways this !* may be called. !* !* The DllMain function should perform additional initialization !* tasks required by the DLL. DllMain should return a value of 1 !* if the initialization is successful. !* !********************************************************************* integer(DWORD) function DllMain (hInstDLL, fdwReason, lpvReserved) !DEC$ ATTRIBUTES STDCALL, DECORATE, ALIAS:”DllMain” :: DllMain use IFWIN use dll_globals integer(HANDLE), intent(IN) :: hinstFDLL integer(DWORD), intent(IN) :: fswReason integer(LPVOID), intent(IN) :: lpvReserved ! Save the module instance handle in a global variable ! This would typically be in a Module or a COMMON block. ghInst = hInst DllMain = 1 return end
One way to use DlgInitWithResourceHandle is to build a resource-only DLL. A resource-only DLL contains an .RC file, but no code. It is useful for building an application that supports multiple languages. You can create a main application and several resource-only DLLs (one for each language) and call the Windows API LoadLibrary routine at the beginning of your application to load the appropriate resource-only DLL. To use a dialog box from the resource-only DLL, first call LoadLibrary (see the Platform SDK online documentation) to return the instance handle that you can use when you call DlgInitWithResourceHandle.
When you create a Fortran DLL project, you can create a resource-only DLL using the Fortran Dynamic Link Library AppWizard.
To create a resource-only DLL:
Select Library as the Intel(R) Fortran project type.
Select Dynamic-link Library in the right pane.
Complete creating the project.
In the Project menu, select Add to Project... Files to add your .RC file and the RESOURCE.H file that defines the identifiers of the controls.
In the Project menu:
Select Properties
Select Linker>Advanced
Set Resource Only DLL to Yes