BaseIDView.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. unit BaseIDView;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, RealICQSkinFrm, InterfaceUI, superobject;
  6. type
  7. TBaseIDViewForm = class(TRealICQSkinForm, IUIIDForm)
  8. private
  9. { Private declarations }
  10. FAutoFree: Boolean;
  11. FFormID: string;
  12. procedure SetFormID(const Value: string);
  13. protected
  14. // procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
  15. // procedure DoShow; override;
  16. procedure DoClose(var Action: TCloseAction); override;
  17. procedure DoShow; override;
  18. public
  19. destructor Destroy; override;
  20. function GetIdentify: Cardinal;
  21. function GetFormID: string;
  22. procedure SetFormInfo(AJson: WideString); virtual;
  23. function GetAutoFree: Boolean;
  24. procedure SetAutoFree(const Value: Boolean);
  25. { Public declarations }
  26. property AutoFree: Boolean read GetAutoFree write SetAutoFree;
  27. property FormID: string read GetFormID write SetFormID;
  28. end;
  29. var
  30. BaseIDViewForm: TBaseIDViewForm;
  31. implementation
  32. uses
  33. ViewManager;
  34. { TBaseIDViewForm }
  35. destructor TBaseIDViewForm.Destroy;
  36. begin
  37. TViewManager.Current.FreeIDView(Self.ClassName, FormID);
  38. inherited;
  39. end;
  40. procedure TBaseIDViewForm.DoClose(var Action: TCloseAction);
  41. begin
  42. inherited;
  43. if FAutoFree then
  44. begin
  45. Action := caFree;
  46. end;
  47. end;
  48. procedure TBaseIDViewForm.DoShow;
  49. begin
  50. inherited;
  51. ChangeUIColor($EADEBA);
  52. end;
  53. function TBaseIDViewForm.GetAutoFree: Boolean;
  54. begin
  55. Result := FAutoFree;
  56. end;
  57. function TBaseIDViewForm.GetFormID: string;
  58. begin
  59. Result := FFormID;
  60. end;
  61. function TBaseIDViewForm.GetIdentify: Cardinal;
  62. begin
  63. Result := Handle;
  64. end;
  65. procedure TBaseIDViewForm.SetAutoFree(const Value: Boolean);
  66. begin
  67. FAutoFree := Value;
  68. end;
  69. procedure TBaseIDViewForm.SetFormID(const Value: string);
  70. begin
  71. FFormID := Value;
  72. end;
  73. procedure TBaseIDViewForm.SetFormInfo(AJson: WideString);
  74. var
  75. AJo: ISuperObject;
  76. begin
  77. AJo := SO(AJson);
  78. if AJo <> nil then
  79. begin
  80. // if AJo.S['url'] <> '' then
  81. // URL := AJo.S['url'];
  82. if AJo.S['caption'] <> '' then
  83. Caption := AJo.S['caption'];
  84. if AJo.I['width'] > 0 then
  85. Width := AJo.I['width'];
  86. if AJo.I['height'] > 0 then
  87. Height := AJo.I['height'];
  88. if AJo.B['center'] then
  89. begin
  90. Top := (Screen.Height - Height) div 2;
  91. Left := (Screen.Width - Width) div 2;
  92. end;
  93. if AJo.B['unsizeable'] then
  94. begin
  95. Constraints.MaxHeight := Height;
  96. Constraints.MaxWidth := Width;
  97. Constraints.MinHeight := Height;
  98. Constraints.MinWidth := Width;
  99. // BorderStyle := bsSingle;
  100. end;
  101. end;
  102. end;
  103. end.