Dear Paul,
I’ve downloaded FTN95 compiler (Personal Edn) v. 4.9 and upgraded it to 4.91. Then I’ve tried to make a simple program with GUI. The need to use a lot of crazy keywords like %ac, %fh, %th, %uw, etc. with ClearWin+ library really frightened me, so I decided to write a program in pure Win32 API.
Well, starting points were as follows:
- One need to declare STDCALL integer function WinMain as a main body of the program.
- It is worth to use alias ‘WinMain’ to preserve the letters’ case.
- As stated in FTN help file, F_STDCALL declaration should be used in such a case. An example of this declaration taken directly from help file:
F_STDCALL INTEGER FUNCTION LIBMAIN(hInst,ul,lpR)
- One need to use module with declarations of all used Win32 API functions and equates. According to FTN95 help, it could be made this way:
Fortran 77 routines that use ClearWin+ and/or the Windows API should include the line INCLUDE <windows.ins>
I think that this is valid for Fortran 90/95 too.
That was a point, and I’ve started. Actually I’ve translated (partially) a BCX BASIC program that shows a window with gradient background colour. After correcting syntax errors, I’ve came to a dead end due to strange compiler behaviour. The main trouble was that I was not able to declare STDCALL function WinMain:
F_STDCALL INTEGER FUNCTION WinMain 'WinMain' (HINSTANCE,HPREVINST,LPCMDLINE,NCMDSH)
Compiler reported an error:
*** 'W' found after FUNCTION where a comma was expected
It was unexpected as the declaration used was definitely in accordance with the example. But if compiler wants a comma, you must provide it! Next attempt was:
F_STDCALL INTEGER FUNCTION, WinMain 'WinMain' (HINSTANCE,HPREVINST,LPCMDLINE,NCMDSH)
Compiler reported:
''' found after WINMAIN where a comma was expected
It puzzled me a bit, but then I made the next attempt:
F_STDCALL INTEGER FUNCTION, WinMain, 'WinMain' (HINSTANCE,HPREVINST,LPCMDLINE,NCMDSH)
Compiler reported:
''' found where a Variable names name was expected
Yes, with duplication in compiler message. But the point is that I was unable to finish properly the declaration of my alias, and I couldn’t find any workaround. So I gave up.
Well, how could I declare F_STDCALL function?