TommyCee
Civil/Environmental
- Nov 6, 2009
- 13
This is my first post to Eng-Tips.
I'm trying to come up to speed in creating simple Windows apps associated w/ Fortran routines and am using Compaq Visual Fortran v6.6.
I am using the book:
Compaq Visual Fortran - A Guide to Creating Windows Applications by Norman Lawrence (2002).
In Chapter 6 (Creating Win32 API Applications) ) are instructions for creating a simple app that displays "Hello Win". This is a Fortran Windows App. using the Single Document Interface (SDI).
Initially, the instruction is to load CVF, then do File|New and choose Fortran Windows Application, then SDI. The rudimentary project gets created and compiles/builds fine to display the About box on execution.
Then we want to add code to HelloWin.f90 to create a simple message that will be displayed on the screen. The only declarations listed (to be added to MainWndProc) are these:
Then, this case is to be added immediately (after Select Case (mesg):
When I attempt to compile, 3 error messages trigger:
This name does not have a type, and must have an explicit type.
The messages apply, respectively, to these variables:
lstrlen; SetTextAlign; TextOut
I presumed that these 3 items were "standard" Windows functions. Yet from the the error messages, it appears that these are vars. that need to be declared. (If this is so, it seems strange that this was not directed in the instructions.)
I added this line to the declaration section for MainWndProc:
integer(4) lstrlen, SetTextAlign, TextOut
The good news is that it complied fine. The bad news is that, during Build, several more errors triggered:
error LNK2001: unresolved external symbol _LSTRLEN@8
error LNK2001: unresolved external symbol _SETTEXTALIGN@8
error LNK2001: unresolved external symbol _TEXTOUT@24
These errors again point to the 3 offending variables and it's surprising that the author never addressed this issue in his instructions (and, sadly, there's no way to get a hold of Norman Lawrence, a prof. at the Australian Maritime College).
Any help is appreciated.
I'm trying to come up to speed in creating simple Windows apps associated w/ Fortran routines and am using Compaq Visual Fortran v6.6.
I am using the book:
Compaq Visual Fortran - A Guide to Creating Windows Applications by Norman Lawrence (2002).
In Chapter 6 (Creating Win32 API Applications) ) are instructions for creating a simple app that displays "Hello Win". This is a Fortran Windows App. using the Single Document Interface (SDI).
Initially, the instruction is to load CVF, then do File|New and choose Fortran Windows Application, then SDI. The rudimentary project gets created and compiles/builds fine to display the About box on execution.
Then we want to add code to HelloWin.f90 to create a simple message that will be displayed on the screen. The only declarations listed (to be added to MainWndProc) are these:
Code:
integer(4) hDC
integer(2) nDrawX
integer(2) nDrawY
type (T_PAINTSTRUCT) ps
type (T_RECT) rc
character (256) FileBuf
Then, this case is to be added immediately (after Select Case (mesg):
Code:
[b]case (WM_PAINT)[/b]
! Get pixel dimensions of Client Area
ret = GetClientRect(hWnd, rc)
! Set up a display context to begin painting
hDC = BeginPaint (hWnd, ps)
FileBuf = "Hello from Win32!"C
ret = DrawText(hdc, FileBuf, lstrlen(FileBuf), rc, DT_CENTER)
FileBuf = "And Again Hello World from Win32!"C
nDrawY = rc%bottom/2 ! pixels to vertical center
nDrawX = rc%right/2 ! pixels to horizontal center
! Set coordinates of TextOut to be center of text string
ret = SetTextAlign(hDC, TA_Center)
ret = TextOut (hDC, nDrawX, nDrawY, FileBuf,lstrlen(FileBuf))
! end painting and release hDC
ret = EndPaint( hWnd,ps)
When I attempt to compile, 3 error messages trigger:
This name does not have a type, and must have an explicit type.
The messages apply, respectively, to these variables:
lstrlen; SetTextAlign; TextOut
I presumed that these 3 items were "standard" Windows functions. Yet from the the error messages, it appears that these are vars. that need to be declared. (If this is so, it seems strange that this was not directed in the instructions.)
I added this line to the declaration section for MainWndProc:
integer(4) lstrlen, SetTextAlign, TextOut
The good news is that it complied fine. The bad news is that, during Build, several more errors triggered:
error LNK2001: unresolved external symbol _LSTRLEN@8
error LNK2001: unresolved external symbol _SETTEXTALIGN@8
error LNK2001: unresolved external symbol _TEXTOUT@24
These errors again point to the 3 offending variables and it's surprising that the author never addressed this issue in his instructions (and, sadly, there's no way to get a hold of Norman Lawrence, a prof. at the Australian Maritime College).
Any help is appreciated.