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!

*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.

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:


integer(4) hDC
integer(2) nDrawX
integer(2) nDrawY
type (T_RECT) rc
character (256) FileBuf

Then, this case is to be added immediately (after Select Case (mesg):


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.

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


eBook - Functional Prototyping Using Metal 3D Printing
Functional prototypes are a key step in product development – they give engineers a chance to test new ideas and designs while also revealing how the product will stand up to real-world use. And when it comes to functional prototypes, 3D printing is rewriting the rules of what’s possible. 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