×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Simple Win App example in CVF - A Guide to Creating Windows Apps.

Simple Win App example in CVF - A Guide to Creating Windows Apps.

Simple Win App example in CVF - A Guide to Creating Windows Apps.

(OP)
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:

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

case (WM_PAINT)
  ! 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.
 

RE: Simple Win App example in CVF - A Guide to Creating Windows Apps.

Those are Windows GDI routines.  You need to add gdi32.lib to the linker list.

RE: Simple Win App example in CVF - A Guide to Creating Windows Apps.

(OP)
Thanks XWB - you were right on.  I added:

    use kernel32
    use gdi32


to function MainWndProc and everything went fine.

I wonder why the author omitted this show-stopping piece.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

White Paper - How ESI is Helping Move New Medical Device Product to Market Quicker & More Cost Effic
Early Supplier Involvement has long been a strategy employed by manufacturers to produce innovative products. Now, it almost seems like a necessity. Because decisions made in the design phase can positively affect product quality and costs, this can help add value to OEM bottom lines. This white paper will discuss many facets of ESI, including why it’s so valuable today, what challenges limit the benefits of ESI, how cost is impacted, and more. Download Now
White Paper - Moving to a Driverless Future
This white paper describes what we see as the best practices to support a sustainable engineering process for autonomous vehicle design. It exposes how to use simulation and testing in common frameworks to enable design exploration, verification and validation for the development of autonomous cars at a system, software and full-vehicle level to drive a mature product development process for automated driving. Download Now
Research Report - How Engineers are Using Remote Access
Remote access enables engineers to work from anywhere provided they have an internet connection. We surveyed our audience of engineers, designers and product managers to learn how they use remote access within their organizations. We wanted to know which industries have adopted remote access, which software they are using, and what features matter most. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close