Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Building a Modeless Dialog Box in 64 bit DLL

$
0
0

I currently have a 32 bit DLL which opens a modeless dialog box.  I want to recompile it as a 64 bit DLL but I get errors at runtime (First-chance exception at 0x772a7eb8 (ntdll.dll) in Dialog_Dll_Exe_New.exe: 0xC0000005: Access violation reading location 0xffffffffef4a0000) and the dialog box fails on initialization.  Bare-bones code is below.  Any help would be appreciated.  Thanks, Steve

  integer(4) 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 dll_globals
    integer(handle) hInst
    integer(dword) ul_reason_being_called
    integer(lpvoid) lpReserved
    ghInst =  hInst
    DllMain = 1
    return
  end

module dll_globals
    use iflogm
    use ifwin
    integer(handle) ghInst      ! Global instance handle for Dialog Box
    type (dialog) gdlg       ! Defines a dialog data type
  end module dll_globals

subroutine dialog_dll_64 (mode) ! DLL Entry point

  ! Expose subroutine dialog_dll_64 to users of this DLL
  !
    !DEC$ ATTRIBUTES DLLEXPORT::dialog_dll_64
    !DEC$ ATTRIBUTES STDCALL, ALIAS:'dialog_dll_64' :: dialog_dll_64
    
  ! Variables
    USE IFLOGM
    USE DLL_GLOBALS
    USE USER32
    USE KERNEL32
    INCLUDE 'resource.fd'    EXTERNAL WinDialogQuit
    INTEGER :: MODE
    LOGICAL :: lret
    CHARACTER (LEN=40) :: VERSION, TITLE
    DATA VERSION / '5.0'/
!    
! Initializes dialog box - sets dialog box name to a Type (dialog) object called "gdlg"
!
        lret = DlgInitWithResourceHandle(IDD_DIALOG2, ghInst, gdlg)
        title = 'LAM '//trim (version) // ' - TIREM 3.14'        CALL DLGSETTITLE (gdlg, title) 
        lret = dlgset(gdlg, IDC_STATIC1, 'Initializing LAM - TIREM')
        lret = DlgSetSub(gdlg, IDCANCEL, WinDialogQuit)
!    
! Show dialog box and declare it a modeless dialog
!
        lret = DlgModeless(gdlg, SW_SHOWNORMAL)       
!
!  Close dialog window
        call dlgexit(gdlg)
        call DlgUninit(gdlg)
!
    return

end subroutine dialog_dll_64

!****************************************************************************
!  FUNCTION: WinDialogQuit ( dlg, id, callbacktype )
!  PURPOSE:  Dialog box callback for initialization and destroy
!****************************************************************************

SUBROUTINE WinDialogQuit( dlg, id, callbacktype )
!DEC$ ATTRIBUTES DEFAULT :: WinDialogQuit

  use user32
  use iflogm

  implicit none

  type (dialog) dlg
  integer id, callbacktype
  if (callbacktype == dlg_clicked) then
    call PostQuitMessage(0)
    call dlgexit(dlg)
  endif
  END SUBROUTINE WinDialogQuit

    program Dialog_64_Exe  ! Main program which calls the DLL

  !DEC$ ATTRIBUTES DLLIMPORT::dialog_dll_64
  !DEC$ ATTRIBUTES STDCALL, ALIAS:'dialog_dll_64' :: dialog_dll_64

    use iflogm
    use dll_globals
    implicit none
    integer :: mode
    mode = 1
    call dialog_dll_64 (mode)
    stop
    end program Dialog_64_Exe

Dialog Resource file:

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Resource1.rc
//
#define IDD_DIALOG2                     103

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        104
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1003
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>