[fpc-pascal] Problem with FPC2.0.2 and windows

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Jan 3 20:44:35 CET 2006


On 03 Jan 2006, at 19:57, Hans MÃ¥rtensson wrote:

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

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

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


More information about the fpc-pascal mailing list