- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have modified an dialog-based executable (which works fine)to make it a DLL so that I can call it from another test executable. I change its WInMain function to a Subroutine called by the test executable. The DLL apparently builds OK. Icopy the DLL and its export .lib to the directory containing thetest executable. When I execute the test executable, which only has a call to the main subroutine of the DLL, I find that the dialog initialisation testfails and I get switched to a programmed message box indicating that the DlgInit failed. Can you advise what might be the problem. The code for the test executable and the main DLL subroutine follow:
Code:
!TEST EXECUTABLE CODE ! beamstest.f90 ! !**************************************************************************** ! ! FUNCTION: WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow ) ! ! PURPOSE: Entry point for the application ! ! COMMENTS: Displays the main window and processes the message loop ! !**************************************************************************** integer*4 function WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : '_WinMain@16' :: WinMain !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : 'WinMain' :: WinMain !DEC$ ENDIF use beamsGlobals implicit none integer*4 hInstance integer*4 hPrevInstance integer*4 lpszCmdLine integer*4 nCmdShow integer*4 IFLAG CALL USRSUB(IFLAG) WinMain = 1 return 99999 & WinMain = 0 end *****************************************************************8 MAIN DLL SUBROUTINE ! beams.f90 ! ! FUNCTIONS: ! USRSUB - Entry point for the application; ! displays the main window; processes the message loop ! beamsSub() - Callback routine for the main dialog box ! SUBROUTINE USRSUB( IFLAG ) !DEC$ ATTRIBUTES DLLEXPORT,REFERENCE,ALIAS:'_USRSUB@4' :: USRSUB use user32 use kernel32 use dflogm use beamsGlobals implicit none integer*4 IFLAG include 'resource.fd' external beamsSub, ComputeSub external InputSub, WirefileSub, IgesfileSub, ReadFirstSub ! Variables type (T_MSG) mesg integer*4 ret logical lret ghInstance = NULL ghModule = GetModuleHandle(NULL) ghwndMain = NULL lret = DlgInit(IDD_BEAMS_DIALOG, gdlg) if (lret == .FALSE.) goto 99999 lret = DlgSetSub(gdlg, IDD_BEAMS_DIALOG, beamsSub) ! lret = DlgSetSub(gdlg, IDC_INPUTFILE, InputSub) lret = DlgSet(gdlg, IDC_INPUTFILENAME, .FALSE., dlg_enable) lret = DlgSet(gdlg, IDC_WIREFILENAME, .FALSE., dlg_enable) lret = DlgSet(gdlg, IDC_IGESFILENAME, .FALSE., dlg_enable) lret = DlgSet(gdlg, IDC_INPUTDIRECTORY, .FALSE., dlg_enable) lret = DlgSet(gdlg, IDC_WIREDIRECTORY, .FALSE., dlg_enable) lret = DlgSet(gdlg, IDC_IGESDIRECTORY, .FALSE., dlg_enable) ! lret = DlgSetSub(gdlg, IDC_WIREFILE, WirefileSub) lret = DlgSet(gdlg, IDC_WIREFILE, .FALSE., dlg_enable) ! lret = DlgSetSub(gdlg, IDC_IGESFILE, IgesfileSub) lret = DlgSet(gdlg, IDC_IGESFILE, .FALSE., dlg_enable) ! lret = DlgSetSub(gdlg, IDC_READFIRSTRECORD, ReadFirstSub) lret = DlgSet(gdlg, IDC_READFIRSTRECORD, .false., dlg_enable) lret = DlgSet(gdlg, IDC_NUMBERSURFACES, .false., dlg_enable) lret = DlgSet(gdlg, IDC_NUMBERPUPIL, .false., dlg_enable) lret = DlgSet(gdlg, IDC_NUMBERFIELD, .false., dlg_enable) ! lret = DlgSetSub(gdlg, IDC_COMPOSITE, ComputeSub) lret = DlgSetSub(gdlg, IDC_INDIVIDUAL, ComputeSub) lret = DlgSetSub(gdlg, IDC_BOTH, ComputeSub) lret = DlgSet(gdlg, IDC_COMPOSITE, .false., dlg_enable) lret = DlgSet(gdlg, IDC_INDIVIDUAL, .false., dlg_enable) lret = DlgSet(gdlg, IDC_BOTH, .false., dlg_enable) ! lret = DlgModal(gdlg) if (lret == .FALSE.) goto 99999 call DlgUninit(gdlg) IFLAG = 1 return 99999 & ret = MessageBox(ghwndMain, "Error initializing application beamsTEST"C, & "Error"C, MB_OK) IFLAG = 0 END SUBROUTINE USRSUB
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oops! I found this in CVF help:
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.
SO that explains that. However, that leaves the question how to use DLGINITWITHRESOURCEHANDLE when I do not have a DLLMAIN or a 'hinst' to hand on?
Message Edited by anthonyrichards on 01-18-2006 06:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regarding my previous post, is is possible to open a dialog from within a DLL and if so, how to do this?
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page