Guest User

Untitled

a guest
Feb 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. unit SpTBXFrameUnit;
  2. {
  3. *What is it?
  4.  
  5. This is TSpTBX support component.
  6.  
  7. When TFrame puts on TSpTBXPanel or TSpTBXDockablePanel,
  8. It has a problem that frame color is black.
  9. This library resolved this problem.
  10.  
  11.  
  12. *How to use
  13.  
  14. First, install SpTBXFrameDesignUnit.pas.
  15.  
  16. File->New menu to new "TSpTBXFrame"
  17.  
  18. or
  19.  
  20. Uses SpTBXFrameUnit, and replace "TFrame" to "TSpTBXFrame".
  21. ex.
  22.  
  23. TMyFrame = class(TSpTBXFrame)
  24. :
  25. end;
  26.  
  27. *notice
  28. If you want to not use owner drawed frame, set SkinedBackground property
  29. to "False".
  30. }
  31.  
  32. interface
  33. uses
  34. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  35. Dialogs, SpTBXControls, SpTBXDkPanels, TntForms;
  36. type
  37. TSpTBXFrame = class(TTntFrame)
  38. protected
  39. FSkinedBackground: Boolean;
  40. procedure SetSkinedBackground(const Value: Boolean);
  41.  
  42. procedure CreateParams(var Params: TCreateParams); override;
  43. procedure WMEraseBkGnd(var Msg: TWMEraseBkGnd); message WM_ERASEBKGND;
  44.  
  45. property ClientHeight stored False;
  46. property ClientWidth stored False;
  47. public
  48. constructor Create(AOwner: TComponent); override;
  49. published
  50. property SkinedBackground: Boolean read FSkinedBackground
  51. write SetSkinedBackground default True;
  52. end;
  53.  
  54. implementation
  55.  
  56. { TSpTBXFrame }
  57. constructor TSpTBXFrame.Create(AOwner: TComponent);
  58. begin
  59. inherited Create(AOwner);
  60. SkinedBackground := True;
  61. end;
  62.  
  63. procedure TSpTBXFrame.CreateParams(var Params: TCreateParams);
  64. begin
  65. inherited CreateParams(Params);
  66. with Params.WindowClass do
  67. style := style or CS_HREDRAW or CS_VREDRAW;
  68. end;
  69.  
  70. procedure TSpTBXFrame.SetSkinedBackground(const Value: Boolean);
  71. begin
  72. if Value then begin
  73. ParentBackGround := False;
  74. ParentColor := False;
  75. end
  76. else begin
  77. ParentBackGround := True;
  78. ParentColor := True;
  79. end;
  80.  
  81. FSkinedBackground := Value;
  82. end;
  83.  
  84. procedure TSpTBXFrame.WMEraseBkGnd(var Msg: TWMEraseBkGnd);
  85. var
  86. ACanvas: TCanvas;
  87. DrawingRect: TRect;
  88. begin
  89. if not FSkinedBackground then begin
  90. inherited;
  91. Exit;
  92. end;
  93.  
  94. Msg.Result := 1;
  95. if (not DoubleBuffered or (TMessage(Msg).wParam = TMessage(Msg).lParam)) then begin
  96. ACanvas := TCanvas.Create;
  97. try
  98. ACanvas.Handle := Msg.DC;
  99.  
  100. DrawingRect := ClientRect;
  101. InflateRect(DrawingRect, 2, 2);
  102. SpDrawXPDockablePanelBody(ACanvas, DrawingRect, True, False);
  103. finally
  104. ACanvas.Handle := 0;
  105. ACanvas.Free;
  106. end;
  107. end;
  108. end;
  109.  
  110. end.
Add Comment
Please, Sign In to add comment