Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-12

Problem with FPC2.0.2 and windows

23 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hans Mårtensson

I decided to improve an old program, I had written for windows, using FreePascal 1.0.10.
Having downloaded FPC 2.0.2, I wanted to use this version, believing that the newer is the better.
So I tried to recompile my old source code with 2.0.2, getting a lot of compile errors.
Anyhow, all of them could be tracked down to 3 problems with call of procedures in the windows unit, and the two of them could easily be repaired. But I have problems with the last one.

The problem was the following program line, using the windows unit: if DialogBoxIndirect(0, pBox2, Window, @Box2Proc) = 0 then exit; The compiler assessed an error in parameter 4. Should not be an address, but a variable.

So I tried:
if DialogBoxIndirect(0, pBox2, Window, Box2Proc) = 0 then exit; And the compiler assessed that the number of parameters was wrong. But this is an error in message, because the number of parameters is right.

Then I tried to define a procedural type TBoxproc and then declared a variable:
var BoxProc: TBoxproc;

and changed my program to:
;
if DialogBoxIndirect(0, pBox2, Window, BoxProc)=0 then exit;

Now FPC compiled my program to the end.

BUT following problems remains:
1) I don’t understand why it should be necessary to use a variable that is assigned to @Box2Proc, in stead of using @Box2Proc directly as the parameter.

2) Even though the compiler produces an exe file, this does not work. The call of DialogBoxIndirect does not produce any dialogue box, but returns having done nothing. Now it is a bit tricky to make this dialogue box business work, because pBox2 must point to a data structure, and if there are errors in this data structure, windows do not produce any error message. But in this case, my data structure worked with the old version of FPC. I have tried to compile exactly the same source files with compiler 1.0.10 and with 2.0.2. The first program worked all right, but the second did not show any dialogue box, when the procedure in question was invoked.

So I suspect that the compiler or the windows unit that comes with the 2.0.2 version has some error.
Does anybody know about these problems?

Jonas Maebe
to Hans Mårtensson
Hans Mårtensson wrote
The problem was the following program line, using the windows unit: if DialogBoxIndirect(0, pBox2, Window, @Box2Proc) = 0 then exit; The compiler assessed an error in parameter 4. Should not be an address, but a variable.

Is your Box2Proc procedure declared as stdcall? In FPC 1.x, the default calling convention was compatible with stdcall, but in 2.x this is no longer the case.

Show quoted text 5 lines
So I tried: if DialogBoxIndirect(0, pBox2, Window, Box2Proc) = 0 then exit; And the compiler assessed that the number of parameters was wrong. But this is an error in message, because the number of parameters is right.

It was probably complaining that too few parameters were specified to Box2Proc, not to DialogBoxIndirect. I guess from this that you are working in either fpc or objfpc mode.

Then I tried to define a procedural type TBoxproc and then declared a variable: var BoxProc: TBoxproc;

How is TBoxProc defined?

Show quoted text 5 lines
and changed my program to: ; if DialogBoxIndirect(0, pBox2, Window, BoxProc)=0 then exit; Now FPC compiled my program to the end.

This is the declaration of DialogBoxIndirect:

function DialogBoxIndirect(hInstance:HINST;
hDialogTemplate:LPCDLGTEMPLATE; hWndParent:HWND;
lpDialogFunc:DLGPROC):longint;

This is the declaration of DLGPROC:

DLGPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM;
_para4:LPARAM):LRESULT;stdcall;

As long as the definition of Box2Proc is compatible with this, there should be no problem.

BUT following problems remains: 1) I don’t understand why it should be necessary to use a variable that is assigned to @Box2Proc, in stead of using @Box2Proc directly as the parameter.

It shouldn't be. Please always supply a fully compilable (or non- compilable in this case, but in any case *complete*) sample if you want us to investigate.

Show quoted text 14 lines
2) Even though the compiler produces an exe file, this does not work. The call of DialogBoxIndirect does not produce any dialogue box, but returns having done nothing. Now it is a bit tricky to make this dialogue box business work, because pBox2 must point to a data structure, and if there are errors in this data structure, windows do not produce any error message. But in this case, my data structure worked with the old version of FPC. I have tried to compile exactly the same source files with compiler 1.0.10 and with 2.0.2. The first program worked all right, but the second did not show any dialogue box, when the procedure in question was invoked. So I suspect that the compiler or the windows unit that comes with the 2.0.2 version has some error. Does anybody know about these problems?

The most likely reason is that your callback is not declared as stdcall. But then the compiler should complain that the calling conventions don't match, and not say that it "Should not be an address, but a variable" (btw, what is the exact error message you get since this error does not exist). And you should not be able to circumvent calling convention requirements by using a procvar, as procvars also have a calling convention associated with them (so that would be a bug in the compiler if you can do that nevertheless).

Jonas

Hans Mårtensson
to Jonas Maebe
Jonas Maebe wrote 12 lines
On 28 Dec 2005, at 23:49, Hans Mårtensson wrote: > The problem was the following program line, using the windows unit: > if DialogBoxIndirect(0, pBox2, Window, @Box2Proc) = 0 then exit; > The compiler assessed an error in parameter 4. Should not be an > address, but a variable. Is your Box2Proc procedure declared as stdcall? In FPC 1.x, the default calling convention was compatible with stdcall, but in 2.x this is no longer the case.

It is declared as stdcall ... and it was so when using ver. 1.0.10.

Show quoted text 10 lines
> So I tried: > if DialogBoxIndirect(0, pBox2, Window, Box2Proc) = 0 then exit; > And the compiler assessed that the number of parameters was wrong. > But this is an error in message, because the number of parameters is > right. It was probably complaining that too few parameters were specified to Box2Proc, not to DialogBoxIndirect. I guess from this that you are working in either fpc or objfpc mode.

I had that option in my mind too, but the number of parameters in Box2Proc is also correct.
I use the fpc compiler on a source code written in the CrEdit program. I have not changed the configuration file that comes with the FreePascal download (except for file location of units).
The only compiler directive I have used in the program is the {$APPTYPE GUI}

Show quoted text 6 lines
> Then I tried to define a procedural type TBoxproc and then declared > a variable: > var BoxProc: TBoxproc; How is TBoxProc defined?

Here is the definition that I used:
Type TBoxProc = Function(x: longword; y: longword; a: longint; b: longint): longint; stdcall;

Show quoted text 20 lines
> and changed my program to: > ; > if DialogBoxIndirect(0, pBox2, Window, BoxProc)=0 then exit; > > Now FPC compiled my program to the end. This is the declaration of DialogBoxIndirect: function DialogBoxIndirect(hInstance:HINST; hDialogTemplate:LPCDLGTEMPLATE; hWndParent:HWND; lpDialogFunc:DLGPROC):longint; This is the declaration of DLGPROC: DLGPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):LRESULT;stdcall; As long as the definition of Box2Proc is compatible with this, there should be no problem.

I cannot see any problem here.
But where are these definitions, I cannot find them in the FPC download, should they be downloaded separately?
Are they exactly the same as the definitions in the Microsoft documentation?

Show quoted text 9 lines
> BUT following problems remains: > 1) I don’t understand why it should be necessary to use a variable > that is assigned to @Box2Proc, in stead of using @Box2Proc directly > as the parameter. It shouldn't be. Please always supply a fully compilable (or non- compilable in this case, but in any case *complete*) sample if you want us to investigate.

Yes of course. I only hoped that someone could point out some simple mistake I had made, or, inform me that there were some known problem with the compiler.
The problem is that my program is large with many units that depends on each other, so it was not easy to pick out the part that invoked the error. Also it seemed very strange to me that the source code after some changes could be compiled with both FPC 1.0.10 AND FPC 2.0.2 and both exe files worked, except for that the FPC 2.0.2 version did not show the dialog boxes.
Now, I will try to construct a simple program that can reproduce the problems.

Show quoted text 24 lines
> 2) Even though the compiler produces an exe file, this does not > work. The call of DialogBoxIndirect does not produce any dialogue > box, but returns having done nothing. Now it is a bit tricky to make > this dialogue box business work, because pBox2 must point to a data > structure, and if there are errors in this data structure, windows > do not produce any error message. But in this case, my data > structure worked with the old version of FPC. I have tried to > compile exactly the same source files with compiler 1.0.10 and with > 2.0.2. The first program worked all right, but the second did not > show any dialogue box, when the procedure in question was invoked. > > So I suspect that the compiler or the windows unit that comes with > the 2.0.2 version has some error. > Does anybody know about these problems? The most likely reason is that your callback is not declared as stdcall. But then the compiler should complain that the calling conventions don't match, and not say that it "Should not be an address, but a variable" (btw, what is the exact error message you get since this error does not exist). And you should not be able to circumvent calling convention requirements by using a procvar, as procvars also have a calling convention associated with them (so that would be a bug in the compiler if you can do that nevertheless).

I tried to omit the stdcall, which made the compiler produce an error message (something like: wrong format of procedure)

Thank you for your careful answer. I will return later if I am able to make a simple sample program that can reproduce the problem. (Or may be I should stick to 1.0.10 that worked for me)

Hans Mårtensson

Jonas Maebe
to Hans Mårtensson
Hans Mårtensson wrote 12 lines
>> So I tried: >> if DialogBoxIndirect(0, pBox2, Window, Box2Proc) = 0 then exit; >> And the compiler assessed that the number of parameters was wrong. >> But this is an error in message, because the number of >> parameters is right. > > It was probably complaining that too few parameters were specified > to Box2Proc, not to DialogBoxIndirect. I guess from this that you > are working in either fpc or objfpc mode. I had that option in my mind too, but the number of parameters in Box2Proc is also correct.

What I mean is that in the above snippet (when compiled in fpc/objfpc mode), you are calling Box2Proc and passing the result of that call as last parameter to DialogBoxIndirect. Since Box2Proc requires 4 parameters and you didn't supply any, the compiler complains that you didn't supply enough parameters.

Show quoted text 5 lines
I use the fpc compiler on a source code written in the CrEdit program. I have not changed the configuration file that comes with the FreePascal download (except for file location of units). The only compiler directive I have used in the program is the {$APPTYPE GUI}

Then you are working in fpc mode.

Show quoted text 17 lines
> This is the declaration of DialogBoxIndirect: > > function DialogBoxIndirect(hInstance:HINST; > hDialogTemplate:LPCDLGTEMPLATE; hWndParent:HWND; > lpDialogFunc:DLGPROC):longint; > > This is the declaration of DLGPROC: > > DLGPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; > _para4:LPARAM):LRESULT;stdcall; > > As long as the definition of Box2Proc is compatible with this, > there should be no problem. I cannot see any problem here. But where are these definitions, I cannot find them in the FPC download, should they be downloaded separately?

They are in the sources of the RTL. The above ones are in rtl/win32/ wininc/ascdef.inc. The sources are available from http:// www.freepascal.org/down/source/sources.html

Are they exactly the same as the definitions in the Microsoft documentation?

They should be.

Thank you for your careful answer. I will return later if I am able to make a simple sample program that can reproduce the problem. (Or may be I should stick to 1.0.10 that worked for me)

It would be nice if you could provide the sample program (and submit it as a bugreport at http://www.freepascal.org/bugs.html), since if you ran into this it's quite possible that other people will do so as well.

Jonas

Hans Mårtensson
to Jonas Maebe
Jonas Maebe wrote 11 lines
They should be. > Thank you for your careful answer. I will return later if I am able > to make a simple sample program that can reproduce the problem. > (Or may be I should stick to 1.0.10 that worked for me) It would be nice if you could provide the sample program (and submit it as a bugreport at http://www.freepascal.org/bugs.html), since if you ran into this it's quite possible that other people will do so as well.

When trying to locate the problem I found out that the first problem was due to my mistake, I'm sorry. The error message was

Error: Incompatible types: got "<address of function(LongWord, LongWord, LongWord, LongInt):LongInt;StdCall>" expected "<procedure variable type of function(LongWord, LongWord, LongInt, LongInt):LongInt;StdCall>"

I interpreted this as if the error was caused by an address in stead of a procedure variable, but actually correcting the type of the 3rd parameter was sufficient to remove the error.
FPC 1.0.10 compiled the statement with a longword in stead of a longint correctly without any comments, but it looks like 2.0.2 has a much stronger type checking.

But my second problem persists. The program is compiled, but the dialogue box does not show up, when using 2.0.2.
Before I go on trying to locate this problem I must take into account that Windows requires the data structure for dialogue boxes to be aligned in a certain way, so I would like to ask the question:

Does PPC 2.0.2 handle alignment of data the same way as former versions? Will the statements (the conditions)

  if (dword(pBoxtemplate) and 1)=1 then pBoxtemplate:=nil;
  if (dword(pBoxtemplate) and 2)=2 then inc(pBoxtemplate);

be treated the same way, and is
pointer(pBoxItem) - pointer(pBoxAllokate)
still equal to the distance between the pointers measured in bytes, regardless of the type of pBoxItem?

Hans Mårtensson

Tomas Hajny
to Hans Mårtensson

Hans Mĺrtensson wrote:
.
.

Does PPC 2.0.2 handle alignment of data the same way as former versions?

.
.

Actually, I don't think so - I believe the default alignment might have changed from 2 to 4 (at least this seems to be indicated by my simple test). You can check this easily for pBoxtemplate^ (or anything else as required) by calling:

WriteLn (SizeOf (pBoxtemplate^));

Furthermore, you can enforce required alignment using {$PACKRECORDS x}.

Tomas

Jonas Maebe
to Hans Mårtensson: When trying to locate the problem I found out that the first problem was due to my…
Hans Mårtensson wrote
Does PPC 2.0.2 handle alignment of data the same way as former versions?

The statements below have nothing to do with alignment.

Will the statements (the conditions) if (dword(pBoxtemplate) and 1)=1 then pBoxtemplate:=nil;

I can only think of one way to interpret this.

if (dword(pBoxtemplate) and 2)=2 then inc(pBoxtemplate);

Somewhere in the past, inc(pBoxtemplate) would have increased pBoxtemplate with one. Nowadays, this increases pBoxtemplate with sizeof(pBoxtemplate^). I don't know when this change was done though, but I'm quite confident it was before 1.0. If this is the behaviour you need, it's ok.

be treated the same way, and is pointer(pBoxItem) - pointer(pBoxAllokate) still equal to the distance between the pointers measured in bytes, regardless of the type of pBoxItem?

Yes.

Jonas

Hans Mårtensson
to Jonas Maebe
Jonas Maebe wrote 17 lines
On 04 Jan 2006, at 17:51, Hans Mårtensson wrote: > Does PPC 2.0.2 handle alignment of data the same way as former > versions? The statements below have nothing to do with alignment. > Will the statements (the conditions) > if (dword(pBoxtemplate) and 1)=1 then pBoxtemplate:=nil; I can only think of one way to interpret this. > if (dword(pBoxtemplate) and 2)=2 then inc(pBoxtemplate);

The type of pBoxtemplate is ^word.
Is it not true that
(dword(pBoxtemplate) and 1)=1
evaluates to TRUE, if and only if pBoxtemplate is NOT aligned to a word boundary (16 bit boundary)?

And then, assuming pBoxtemplate is aligned to word boundary, is it not true, that
if (dword(pBoxtemplate) and 2)=2
evaluates to TRUE, if pBoxtemplate is NOT aligned to a dword boundary (32 bit boudary), causing the statement

  if (dword(pBoxtemplate) and 2)=2 then inc(pBoxtemplate);

to make the pBoxtemplate align to a dword boundary (by eventually adding 2 to pBoxtemplate (because sizeof(word)=2)??

Hans Mårtensson

Jonas Maebe
to Hans Mårtensson
Hans Mårtensson wrote 19 lines
>> Does PPC 2.0.2 handle alignment of data the same way as former >> versions? > > The statements below have nothing to do with alignment. > The type of pBoxtemplate is ^word. Is it not true that (dword(pBoxtemplate) and 1)=1 evaluates to TRUE, if and only if pBoxtemplate is NOT aligned to a word boundary (16 bit boundary)? And then, assuming pBoxtemplate is aligned to word boundary, is it not true, that if (dword(pBoxtemplate) and 2)=2 evaluates to TRUE, if pBoxtemplate is NOT aligned to a dword boundary (32 bit boudary), causing the statement if (dword(pBoxtemplate) and 2)=2 then inc(pBoxtemplate); to make the pBoxtemplate align to a dword boundary (by eventually adding 2 to pBoxtemplate (because sizeof(word)=2)??

Yes, but this is independent of how the compiler handles alignment of data.

Jonas

Hans Mårtensson
to Jonas Maebe
Jonas Maebe wrote 22 lines
On 04 Jan 2006, at 21:51, Hans Mårtensson wrote: The type of pBoxtemplate is ^word. > Is it not true that > (dword(pBoxtemplate) and 1)=1 > evaluates to TRUE, if and only if pBoxtemplate is NOT aligned to a > word boundary (16 bit boundary)? > > And then, assuming pBoxtemplate is aligned to word boundary, is it > not true, that > if (dword(pBoxtemplate) and 2)=2 > evaluates to TRUE, if pBoxtemplate is NOT aligned to a dword > boundary (32 bit boudary), causing the statement > if (dword(pBoxtemplate) and 2)=2 then inc(pBoxtemplate); > to make the pBoxtemplate align to a dword boundary (by eventually > adding 2 to pBoxtemplate (because sizeof(word)=2)?? Yes, but this is independent of how the compiler handles alignment of data.

OK, then I really don't understand where the problem is.

It seems difficult to me to supply a bug report, because it is still so uncertain where the problem lies.
But I attach the source code to my test program, in case you can do anything with it.

When I compile this source code with FPC 1.0.10, it produces a program that makes a window with one menu item. When you click on it, a dialogue box pops up.

But when I compile the same source code with FPC 2.0.2, I still get a program that makes the window. But the dialogue box does not show, when you click the menu item.

Hans Mårtensson

Jonas Maebe
to Hans Mårtensson
Hans Mårtensson wrote 7 lines
When I compile this source code with FPC 1.0.10, it produces a program that makes a window with one menu item. When you click on it, a dialogue box pops up. But when I compile the same source code with FPC 2.0.2, I still get a program that makes the window. But the dialogue box does not show, when you click the menu item.

I hope someone else can take it over from here, because I don't have Windows (or even a computer which can run Windows).

Jonas

Hans Mårtensson
to Jonas Maebe
Jonas Maebe wrote 14 lines
On 04 Jan 2006, at 23:46, Hans Mårtensson wrote: > When I compile this source code with FPC 1.0.10, it produces a > program that makes a window with one menu item. When you click on > it, a dialogue box pops up. > > But when I compile the same source code with FPC 2.0.2, I still get > a program that makes the window. But the dialogue box does not show, > when you click the menu item. I hope someone else can take it over from here, because I don't have Windows (or even a computer which can run Windows).

OK, thank you for your help so far.
I will try to do further experiments in order to locate the problem. I think it must be in the data structure that defines the dialog box, which the two compiler versions generate differently.

I appreciate very much the work done by the people behind FPC. Not only because it is free and advanced, but also because Pascal is nicer than any other programming language I have seen, in my opinion

Hans Mårtensson

Jonas Maebe
to Hans Mårtensson
Hans Mårtensson wrote
OK, thank you for your help so far. I will try to do further experiments in order to locate the problem. I think it must be in the data structure that defines the dialog box, which the two compiler versions generate differently.

You can try writing the size of the structure using sizeof(), and the individual offset using things like "pointer(@recordvar.field) - pointer(@recordvar)", and then compare the values between the 1.0.10 and 2.0.2 version.

I appreciate very much the work done by the people behind FPC. Not only because it is free and advanced, but also because Pascal is nicer than any other programming language I have seen, in my opinion

Thanks!

Jonas

Martin Schreiber
to Jonas Maebe: I hope someone else can take it over from here, because I don't have Windows (or even a…
Jonas Maebe wrote
I hope someone else can take it over from here, because I don't have Windows (or even a computer which can run Windows).

The problem is in rtl/win32/wininc/struct.inc, the smallint's were integer's:

    DLGTEMPLATE = packed record //from rtl/win32/wininc/struct.inc
          style : DWORD;
          dwExtendedStyle : DWORD;
          cdit : WORD;
          x : smallint; //integer;
          y : smallint; //integer;
          cx : smallint; //integer;
          cy : smallint; //integer;
       end;
     pdlgtemplate = ^dlgtemplate;
     DLGITEMTEMPLATE = packed record
          style : DWORD;
          dwExtendedStyle : DWORD;
          x : smallint; //integer;
          y : smallint; //integer;
          cx : smallint; //integer;
          cy : smallint; //integer;
          id : WORD;
       end;

Who makes the bug report?

Martin

Jonas Maebe
to Martin Schreiber
Martin Schreiber wrote 5 lines
> I hope someone else can take it over from here, because I don't have > Windows (or even a computer which can run Windows). The problem is in rtl/win32/wininc/struct.inc, the smallint's were integer's:

Thanks, I've committed your changes. If someone can verifies it works in 2.1.1 tomorrow, I'll merge it back to 2.0.3 as well.

Jonas

Hans Mårtensson
to Jonas Maebe
Jonas Maebe wrote 10 lines
On 06 Jan 2006, at 19:12, Martin Schreiber wrote: > The problem is in rtl/win32/wininc/struct.inc, the smallint's were > integer's: Thanks, I've committed your changes. If someone can verifies it works in 2.1.1 tomorrow, I'll merge it back to 2.0.3 as well.

I have downloaded the 2.1.1 snapshot and compiled my testprogram with it, and the problem is still there: no dialog box showes up.

Then, by help of the windows function GetLastError, I have found out that windows in my program after call to
DialogBoxIndirect(0,pBox2, Window, @Box2Proc)
returns LastError 1812, meaning "resource not found".

That made me think about the first two parameters. The first one should be a handle to an instance of the module. Here I use 0, believing that this makes windows use the current module. I'm not sure about this, but it worked in the program compiled with FPC 1.0.10, and windows hasn't changed.

Next the pBox2 should point to the data structure, defining the dialog box. The data should be in global memory.
I have constructed the data by help of some pointers of type ^word, pointing to something, allocated by getmem, using move to put data there, then finally assigned the pBox2 that is of type pointer. (typeless I mean).
I can't see if that possibly can be treated diffently in the 2.0.2 compiler?

Hans Mårtensson

Jonas Maebe
to Hans Mårtensson
Hans Mårtensson wrote
I have downloaded the 2.1.1 snapshot and compiled my testprogram with it, and the problem is still there: no dialog box showes up.

Can you check the date of the compiler with "fpc -iD"? As far as I know no new snapshot was built last night because of errors compiling the graph unit.

Jonas

Martin Schreiber
to Hans Mårtensson: I have downloaded the 2.1.1 snapshot and compiled my testprogram with it, and the problem…
Hans Mårtensson wrote
I have downloaded the 2.1.1 snapshot and compiled my testprogram with it, and the problem is still there: no dialog box showes up.

Your testcase worked for me with FPC 2.0.2 and the modified DLGTEMPLATE and DLGITEMTEMPLATE.

Then, by help of the windows function GetLastError, I have found out that windows in my program after call to DialogBoxIndirect(0,pBox2, Window, @Box2Proc) returns LastError 1812, meaning "resource not found".

This is the same error as you get with FPC 2.0.2 and the unmodified records.

Martin

Hans Mårtensson
to Martin Schreiber: Your testcase worked for me with FPC 2.0.2 and the modified DLGTEMPLATE and…
Martin Schreiber wrote
Your testcase worked for me with FPC 2.0.2 and the modified DLGTEMPLATE and DLGITEMTEMPLATE.

Yes, I'm convinced that the problem lies where you have pointed it out. I have let my test program show sizeof(DLGTEMPLATE) and the output from the version compiled with 2.0.2 was
sizeof(DLGTEMPLATE)=26
while the old working version had
sizeof(DLGTEMPLATE)=18
which fits to 4 longint in stead of 4 shortint.

Now, I'm not familiar with the development of the PFC, where and when can I download the corrected version of 2.0.2?

Hans Mårtensson

Jonas Maebe
to Hans Mårtensson
Hans Mårtensson wrote
Now, I'm not familiar with the development of the PFC, where and when can I download the corrected version of 2.0.2?

You can't, Martin Schreiber compiled his own corrected version.

Jonas

Martin Schreiber
to Hans Mårtensson: Yes, I'm convinced that the problem lies where you have pointed it out. I have let my…
Hans Mårtensson wrote
Now, I'm not familiar with the development of the PFC, where and when can I download the corrected version of 2.0.2?

Copy the modified definition in type section of your program file:

Program test;
// Program for testing dialogue boxes
{$APPTYPE GUI}
Uses windows;
Const
  AppName = 'Lydexperiment';
type
     DLGTEMPLATE = packed record //from rtl/win32/wininc/struct.inc
          style : DWORD;
          dwExtendedStyle : DWORD;
          cdit : WORD;
          x : smallint;
          y : smallint;
          cx : smallint;
          cy : smallint;
       end;
     DLGITEMTEMPLATE = packed record
          style : DWORD;
          dwExtendedStyle : DWORD;
          x : smallint;
          y : smallint;
          cx : smallint;
          cy : smallint;
          id : WORD;
       end;
var
  AMessage: Msg; hWindow: HWnd;
  pbox2: pointer; box2var1, box2var2: longint;
.....

Martin

Hans Mårtensson
to Martin Schreiber
Martin Schreiber wrote 5 lines
Copy the modified definition in type section of your program file: .......

Yes, it works!
Which means that if you put in your own type definitions, they will simply overrule the system definitions.
I wasn't aware of that trick.
So I can do with that until a corrected version of FPC is released.

Thank you very much.

Hans Mårtensson