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.

DlgGetRes failing

Even_Bergseng
Beginner
490 Views
Hello.

I have recently started to program in Fortran after inheriting the responsibillity of an old program. It's a mix up of different Fortran versions and was previously handled in CVF. I have now emmigrated the code to Visual Studio 2008, but I am having some trouble to get it to work.

Everything compiles just fine, but when I run the exe-file (or Debug) DlgINIT seems to file. I have steppedinto the IFLOGM.f90 file to look for the error there, and it seems that something goes wrong in DlgGetRes, more specifically this part:

if ( .not. DlgGetRes( id, hinst, dlgres ) ) then
r = .false.
return

I am most unfamiliar with Fortran and at loss with what is going on here. Can anyone suggest how to debug this?



Here is an axtract of the main file:

----------------------------------------------------------------------------------------------------------

! FWin.f90
! FUNCTIONS:
! WinMain() - Entry point for the application;
! displays the main window; processes the message loop
! FWinSub() - Callback routine for the main dialog box
! FWinApply()- Callback routine for the APPLY button
!****************************************************************************
! 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 user32
use kernel32
use dflogm
use iflogm ! m med i henhold til Hjelp-funksjonen (F1)
use dfcom
use dfauto
use FWinGlobals

implicit none

integer*4 hInstance
integer*4 hPrevInstance
integer*4 lpszCmdLine
integer*4 nCmdShow

include 'const.fi'
include 'resource.fd'

external FWinSub
external FWinCancel

! Variables
type (T_MSG) mesg
integer*4 ret
logical*4 lret
integer gridmode,snum,tnum,pbarmode,i
real tsfac(6),tsum
data tsfac/0.4354,0.6689,0.7302,0.9411,1.0535,0.8601/
ghInstance = hInstance
ghModule = GetModuleHandle(NULL)
ghwndMain = NULL
call COMINITIALIZE(ret)

! ---SIMA.INI ----------------
open(unit=99,file="sima.ini",type='old')
read(99,'(29x,i1,10x,i5,12x,i5,9x,i5,9x,f3.1,9x,i5)') gridmode,pbarmode,snum,tnum,rndcut,fboard
read(99,'(f5.0)') tsum
do 20 i=1,6
if (tsum.gt.0.) then
tfac(i)=(tsum/1000.0)**tsfac(i)
else
tfac(i) = 1.0
endif
20 continue
close(unit=99)
!----------------------------

if (gridmode.eq.0) then
lret = DLGINIT(IDD_FWIN_DIALOG, gdlg)
if (lret == .FALSE.) goto 99999
lret = DlgSetSub(gdlg, IDD_FWIN_DIALOG, FWinSub)
lret = DlgModeless(gdlg, nCmdShow)
if (lret == .FALSE.) goto 99999

if (pbarmode.eq.1 .and. tnum.gt.1) then
call SetLabel(snum,tnum)
end if
endif
call LAHTO
call MAIN(gridmode)
!----------------------
! call PostQuitMessage(0)
if (gridmode.eq.0) call DlgUninit(gdlg)
call COMUNINITIALIZE()

! aaa=mesg.wparam
! WinMain = mesg.wParam
WinMain = exitvalue
return

99999 &
ret = MessageBox(ghwndMain, "Error initializing application FWin"C, &
"Error"C, MB_OK)
call COMUNINITIALIZE()
WinMain = 0
end

-------------------------------------------------------------------------------
0 Kudos
2 Replies
anthonyrichards
New Contributor III
490 Views
Confirm that it is a windows 32-bit program that provides a dialog-based GUI.
Can you post the Resource file (.RC)?
Can you post a version of Fwinsub that works?
You do not appear to have code that assigns call-backs to dialog controls.
You specify FWincancel as an external subroutine, but do not assign it to a control using DlgSetSub (unless that is done in FWInSUb?).
We need more information than you have supplied. Exactly what messages do you get?
Do you even get to see the dialog?
0 Kudos
Even_Bergseng
Beginner
490 Views
Pardon my Fortran!

It appears that I thought the header fil 'resource.fd' in my project was the Resource file, so when you specifically asked for the '*.rc' file I had to rethink that. Found it in my project folder... Adding it to my project solved the problem.

Thanks so much, Anthony! :-)
0 Kudos
Reply