[fpc-devel]Delphi incompatibity
Pavel V. Ozerski
pavel at insect.mail.iephb.ru
Mon Mar 12 16:14:07 CET 2001
Hello,
1) I tried to switch on properties in BP-style objects. My first attempt is very rough:
I disabled in procedure property_dec (pdecobj.pas) initial checking for a class.
But my example not only can be compiled but also runs and gives correct result!
{$APPTYPE CONSOLE}
{$MODE OBJFPC}
type
Tobj1=object
private
xx:longint;
protected
procedure SetX(Value:longint);
procedure Init;virtual;
public
constructor Create;
property X: longint read xx write SetX;
end;
procedure TObj1.SetX(Value:longint);
begin
xx:=Value;
end;
constructor TObj1.Create;
begin
Init;
end;
procedure TObj1.Init;
begin
FillChar( Pointer( Integer( @Self ) + 8 )^, Sizeof( Self ) - 8, 0 );
// Self.fRefCount := 0;
end;
var
Obj1:Tobj1;
begin
Obj1.Create;
Obj1.x:=1;
writeln(Obj1.x);
end.
2) While my experiments I found a bug in Windows unit (really, in func.inc). This unit contains a reference to function
EnumTaskWindows as located in USER32.dll. But at least in NT 4 user32.dll does not contain this function. In Delphi 3 RTL
this function is implemented as
function EnumTaskWindows(hTask: THandle; lpfn: FARPROC; lParam: LPARAM): BOOL;
begin
Result := EnumThreadWindows(DWORD(hTask), lpfn, lParam);
end;
I think, for Win32 better (and faster) would be
function EnumTaskWindows(hTask:HWND; lpfn:FARPROC; lParam: LPARAM): BOOL;stdcall;
external 'user32' name 'EnumThreadWindows';
because in Win32 Thandle and DWORD are 4-byte integers.
Pavel
More information about the fpc-devel
mailing list