uBasePluginForm.pas 2.5 KB

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