Question about beginpaint

Question about beginpaint

Hello,

i am transfering an old CVF program towards IVF (11.1.070).

One construct is not working. I have compilid (i hope) the needed information:

use dfwina
use dfwin
use dflogm

type (T_PAINTSTRUCT) ps
integer(4)     hDlg , hDC

hdc = BeginPaint(hDlg, ps)

error #6633: The type of the actual argument differs from the type of the dummy argument.   [PS]

What has been changed?

Thanks in advance

Frank

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The code you posted compiles without error in 11.1.078. There's something else you haven't shown us.  As an aside, I would recommend you change the handle declarations to integer(HANDLE) so that they'll be 64-bit ready.

Retired 12/31/2016

What about two changes like:

hdc -> needs to be declared as HDC type
hDlg -> needs to be declared as HWND type

ifort doesn't use INTEGER(HDC) and the like because dummy arguments to Windows API functions can have names like 'hdc'. This is more of an acute problem in Fortran than in C because Fortran is case-insensitive and the calling program can use dummy argument names as keywords in function invocations. Thus it matters in Fortran what you actually name the dummy arguments and you can't have a dummy argument declared as

INTEGER(HDC), value :: hdc

Thus ifort just has the

INTEGER, PARAMETER :: HANDLE = C_INTPTR_T

named constant. There are a couple of situations where name collisions were avoided by renaming, like WPARAM and LPARAM are called INTEGER(fWPARAM) and INTEGER(fLPARAM) because Windows callbacks have dummy arguments call wParam and lParam.

That interface body that works in gfortran will only work in ifort in 64-bit mode. Intel does not allow you to mix STDCALL with BIND(C) except in 64-bit mode where STDCALL is the same as CDECL anyway. The KIND numbers here, given as C_INTPTR_T, while correct, would better have been written as HANDLE, so as to be compatible with ifort usage. This doesn't lead to the error message in your previous message, however, because the argument PS, not HDLG, is the one with the wrong type. In the gfortran interface body, the type PAINTSTRUCT_T is referenced, whereas in your ifort code you use the type T_PAINTSTRUCT. These are different in that the former is BIND(C) but not the latter. Actually PAINTSTRUCT_T is just an unfortunate misspelling, but even if that were corrected in module win32_types and user32, your application would fail to link because ifort would try to invoke a CDECL function rather than a STDCALL one. This would work in 64-bit ifort except for your declarations of hDlg and hDC as INTEGER(4) rather than integer(HANDLE). As a general rule, the gfortran interface bodies will work in 64-bit ifort. It's best in ifort to just use IFWIN and hope for the best and change the type names to prepend T_ rather than append _T.

The source you show does not cause an error in 11.1.  Please post a small but complete program that gives you the error.

My suggestion for using INTEGER(HANDLE) was unrelated to your problem - just an observation in passing.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today