uBasePluginForm.pas 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. unit uBasePluginForm;
  2. interface
  3. uses
  4. Forms, uIPluginForm, Classes, superobject,
  5. ComObj, SysUtils,
  6. mybean.core.intf;
  7. type
  8. TBasePluginForm = class(TForm,
  9. IPluginForm,
  10. IBeanConfigSetter)
  11. private
  12. FInstanceID: string;
  13. protected
  14. __pass:AnsiString;
  15. FBeanConfigStr:string;
  16. procedure DoClose(var Action: TCloseAction); override;
  17. protected
  18. function getCaption: PAnsiChar; stdcall;
  19. procedure setCaption(pvCaption: PAnsiChar); stdcall;
  20. protected
  21. /// <summary>
  22. /// 设置配置中的Config
  23. /// </summary>
  24. /// <param name="pvBeanConfig">
  25. /// 配置文件中JSon格式的字符串
  26. /// </param>
  27. procedure setBeanConfig(pvBeanConfig: PAnsiChar); virtual; stdcall;
  28. protected
  29. //获取实例Handle
  30. function getInstanceID: string; stdcall;
  31. //获取窗体对象
  32. function getObject: TObject; stdcall;
  33. procedure showAsMDI; stdcall;
  34. function showAsModal: Integer; stdcall;
  35. procedure showAsNormal(); stdcall;
  36. //关闭和释放窗体
  37. procedure closeForm; stdcall;
  38. protected
  39. procedure FreeObject; stdcall;
  40. public
  41. constructor Create(AOwner: TComponent); override;
  42. destructor Destroy; override;
  43. end;
  44. implementation
  45. constructor TBasePluginForm.Create(AOwner: TComponent);
  46. begin
  47. inherited Create(AOwner);
  48. FInstanceID := CreateClassID;
  49. end;
  50. destructor TBasePluginForm.Destroy;
  51. begin
  52. inherited Destroy;
  53. end;
  54. procedure TBasePluginForm.DoClose(var Action: TCloseAction);
  55. begin
  56. if not (fsModal in self.FFormState) then action := caFree;
  57. inherited DoClose(Action);
  58. end;
  59. function TBasePluginForm.getCaption: PAnsiChar;
  60. begin
  61. __pass := self.Caption;
  62. Result := PAnsiChar(__pass);
  63. end;
  64. function TBasePluginForm.getInstanceID: string;
  65. begin
  66. Result := FInstanceID;
  67. end;
  68. function TBasePluginForm.getObject: TObject;
  69. begin
  70. Result := Self;
  71. end;
  72. procedure TBasePluginForm.FreeObject;
  73. begin
  74. Self.Free;
  75. end;
  76. procedure TBasePluginForm.setBeanConfig(pvBeanConfig: PAnsiChar);
  77. begin
  78. FBeanConfigStr :=String(AnsiString(pvBeanConfig));
  79. end;
  80. procedure TBasePluginForm.setCaption(pvCaption: PAnsiChar);
  81. begin
  82. self.Caption := pvCaption;
  83. end;
  84. procedure TBasePluginForm.showAsMDI;
  85. begin
  86. self.FormStyle := fsMDIChild;
  87. self.WindowState := wsMaximized;
  88. self.Show;
  89. end;
  90. function TBasePluginForm.showAsModal: Integer;
  91. begin
  92. Result := ShowModal();
  93. end;
  94. procedure TBasePluginForm.showAsNormal;
  95. begin
  96. self.Show;
  97. end;
  98. { TBasePluginForm }
  99. procedure TBasePluginForm.closeForm;
  100. begin
  101. Self.Close;
  102. end;
  103. end.