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

DlgModeless in dll

John_Lee1
Beginner
449 Views
I try to setup a dialog in a dll.

Below is my dllmain function:

integer function DllMain (hInst, ul_reason_being_called, lpReserved)
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_DllMain@12' :: DllMain
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'DllMain' :: DllMain
!DEC$ ENDIF
use minewinGlobals
use DFWIN
implicit none
integer(HANDLE) hInst
integer(DWORD) ul_reason_being_called
integer(HANDLE) lpReserved
! Save the module instance handle in a global variable
ghinst = hInst
! Return 1 to indicate success
DllMain = 1
return
end function DllMain

and the functtion which setups dialog:

integer function Mine( )
!DEC$ ATTRIBUTES DLLEXPORT::Mine
use user32
use dflogm
use minewinGlobals
USE DFLIB

IMPLICIT NONE

include 'resource.fd'
external minewinSub
integer(LRESULT) lret

lret = DlgInitWithResourceHandle(IDD_MineWIN_DIALOG, ghinst,gdlg)
if (lret == .FALSE.) goto 99999
lret = DlgSetSub(gdlg, IDD_MineWIN_DIALOG, minewinSub)
lret = DlgModeless(gdlg, SW_SHOWNORMAL,0)
if (lret == .FALSE.) goto 99999

In minewinGlobals define:

integer(HANDLE) ghinst
integer(HANDLE) hwndParent


DlgModeless returns FALSE. IDD_MineWIN_DIALOG has been tested in a winmain program.

Apprecate your help!
0 Kudos
2 Replies
anthonyrichards
New Contributor III
449 Views
Try using GetModuleHandle("YOURDLLNAME.DLL") instead of the instance handle
(perhaps add the full path to the DLL).
0 Kudos
John_Lee1
Beginner
449 Views
I tried use GetModuleHandle("YOURDLLNAME.DLL"), and this time the error is on DlgInitWithresourcehandle. I add the full path of the dll.

By the way, I am using x64 platform for dll and main pogram. Does it metter?
0 Kudos
Reply