uPluginObject.pas 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. unit uPluginObject;
  2. interface
  3. uses
  4. Classes, SysUtils, uICaption;
  5. type
  6. TSetCaptionEvent = procedure(Sender: TObject; pvCaption:String) of object;
  7. TPluginObject = class(TInterfacedObject, ICaptionManager)
  8. private
  9. FPlugin: IInterface;
  10. FInstanceID: string;
  11. FcanClose: Boolean;
  12. FOnSetCaption: TSetCaptionEvent;
  13. public
  14. function _AddRef: Integer; stdcall;
  15. function _Release: Integer; stdcall;
  16. public
  17. constructor create();
  18. destructor Destroy; override;
  19. function getCaption: PAnsiChar; stdcall;
  20. procedure setCaption(pvCaption: PAnsiChar); stdcall;
  21. property InstanceID: string read FInstanceID write FInstanceID;
  22. //²»ÄÜÊÖ¶¯¹Ø±Õ
  23. property canClose: Boolean read FcanClose write FcanClose;
  24. property OnSetCaption: TSetCaptionEvent read FOnSetCaption write FOnSetCaption;
  25. property Plugin: IInterface read FPlugin write FPlugin;
  26. end;
  27. implementation
  28. constructor TPluginObject.create();
  29. begin
  30. inherited Create;
  31. FcanClose:= true;
  32. end;
  33. destructor TPluginObject.Destroy;
  34. begin
  35. FPlugin := nil;
  36. inherited Destroy;
  37. end;
  38. function TPluginObject.getCaption: PAnsiChar;
  39. begin
  40. Result := '';
  41. end;
  42. procedure TPluginObject.setCaption(pvCaption: PAnsiChar);
  43. begin
  44. if Assigned(FOnSetCaption) then
  45. begin
  46. FOnSetCaption(Self, String(AnsiString(pvCaption)));
  47. end;
  48. end;
  49. function TPluginObject._AddRef: Integer;
  50. begin
  51. Result := -1;
  52. end;
  53. function TPluginObject._Release: Integer;
  54. begin
  55. Result := -1;
  56. end;
  57. end.