{$IFDEF in_interface} type IObject = interface ['{A6A98F7F-B435-478C-BA80-8259A1473450}'] // FIXME different GUID depending on OS? function GetHandle : TExternalHandle; property Handle : TExternalHandle read GetHandle; end; TObject = class(TInterfacedObject, IObject, IInterface) protected fHandle : TExternalHandle; fBOwnsHandle : TBoolean; private fMessageMap : TMessageMap; protected function GetHandle : TExternalHandle; protected procedure DeleteUnderlyingObject; virtual; abstract; procedure InitMessageMap(var aMessageMap : TMessageMap); virtual; public destructor Destroy; override; published { when creating, call this as: inherited Reuse(CheckError(Windows.CreateWindow(...)), True); } {$IFDEF X11} private fDisplay : PDisplay; public property Display : PDisplay read fDisplay; published constructor Reuse(aDisplay : PDisplay; aHandle : TExternalHandle; aBOwnsHandle : TBoolean); {$ELSE} constructor Reuse(aHandle : TExternalHandle; aBOwnsHandle : TBoolean); {$ENDIF} property Handle : TExternalHandle read GetHandle; end; {$ENDIF} {$IFDEF in_implementation} {$IFDEF X11} constructor TObject.Reuse(aDisplay : PDisplay; aHandle : TExternalHandle; aBOwnsHandle : TBoolean); begin fDisplay := aDisplay; fHandle := aHandle; fBOwnsHandle := aBOwnsHandle; end; {$ELSE} constructor TObject.Reuse(aHandle : TExternalHandle; aBOwnsHandle : TBoolean); begin fHandle := aHandle; fBOwnsHandle := aBOwnsHandle; InitMessageMap(fMessageMap); end; {$ENDIF} procedure TObject.InitMessageMap(var aMessageMap : TMessageMap); begin end; destructor TObject.Destroy; begin if (fBOwnsHandle) then DeleteUnderlyingObject; inherited Destroy; end; function TObject.GetHandle : TExternalHandle; begin Result := fHandle; end; {$ENDIF}