[fpc-pascal] Problem with FPC2.0.2 and windows
Hans Mårtensson
hm at os.dk
Wed Dec 28 23:49:34 CET 2005
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:
BoxProc:=@Box2Proc;
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?
More information about the fpc-pascal
mailing list