- This topic has 15 replies, 4 voices, and was last updated 4 years, 6 months ago by SpeedTI.
-
AuthorPosts
-
May 24, 2020 at 5:51 pm #68867SpeedTIParticipant
I would like to suggest the creation of a Layout type component similar or equal to the TLayout component used in Delphi for creating Apps.
I believe it would be very interesting, because in addition to being very “light”, they would partially avoid the use of components of the type TsPanel or TsGroupBox used in many cases just to group other components.Thank you.
Regards
Valdir SolaMay 24, 2020 at 6:30 pm #68868HeDiBoParticipantWhy do you think the use of TPanel with Transparent skin is inferior to a layout setup?
May 24, 2020 at 7:34 pm #68869SpeedTIParticipantHello!
I did not say that the TPanel component configured in this way is better or worse (I don’t particularly like to use it), I am referring to practicality, besides that it does not have the transparency feature itself. The TPanel after being inserted, needs several configurations to fulfill this purpose. If there was a TLayout it would simply be added to the Form without requiring any adjustment, not to mention that it should be more “light” as I said earlier.Regards
Valdir SolaMay 25, 2020 at 5:29 pm #68871HeDiBoParticipantI must disagree with you, TLayout is by no means a light component.
You may find the following lightweight component useful:unit acLayout; interface uses System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, sPanel; type TacLayout = class(TsPanel) private { Private declarations } protected { Protected declarations } public constructor Create(AOwner: TComponent); override; procedure Loaded; override; published { Published declarations } end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TacLayout]); end; { TacLayout } constructor TacLayout.Create(AOwner: TComponent); begin inherited; SkinData.SkinSection := 'TRANSPARENT'; BevelOuter := bvNone; Ctl3D := False; ShowCaption := False; ParentCtl3D := False; ParentFont := False; // Although the following would make sense, after the Create event // ... apparently the BevelKind property is reset again during load. // ... So this logic is moved to after the Loaded event. // if csDesigning in ComponentState then BevelKind := bkFlat // else BevelKind := bkNone; end; procedure TacLayout.Loaded; begin inherited; // Moved from Create event: if csDesigning in ComponentState then BevelKind := bkFlat else BevelKind := bkNone; end; end.
Hope this helps.
May 25, 2020 at 7:22 pm #68872SpeedTIParticipantIt’s a great implementation.
Thank you.Regards
Valdir SolaMay 25, 2020 at 8:16 pm #68873HeDiBoParticipantFor some reason the BevelKind is bvNone at design time. I don’t know any more where to set it. Maybe Serge can help here.
May 25, 2020 at 9:12 pm #68874SpeedTIParticipantI made this change and apparently resolved:
constructor TsLayout.Create(AOwner: TComponent); begin
inherited;
SkinData.SkinSection := ‘TRANSPARENT’;
BevelOuter := bvNone;
Ctl3D := False;
ShowCaption := False;
ParentCtl3D := False;
ParentFont := False;
// Although the following would make sense, after the Create event
// … apparently the BevelKind property is reset again during load.
// … So this logic is moved to after the Loaded event.
BevelKind := bkFlat;
end;procedure TsLayout.Loaded;
begin
inherited;
// Moved from Create event:
BevelKind := bkNone;
end;Regards
Valdir SolaMay 26, 2020 at 12:28 pm #68875HeDiBoParticipantSerge,
Why is the BevelKind property changed after the Create constructor?
And why does this even work. Is Loaded not called at design time?
Thank you for clarifying this.May 26, 2020 at 12:49 pm #68876HeDiBoParticipantLoaded procedure is only called if the component is streamed in with the form. If it is created dynamically in code, the Loaded procedure is not called. So, this solution may work, but is by no means foolproof.
May 26, 2020 at 2:28 pm #68877HeDiBoParticipantI know now why this is such a pain. Every component that is created at design time gets its properties listed in the dfm file. That file is streamed in by the Reader AFTER the creation. Because on design time, the BevelKind is bkFlat, that is the value streamed to the dfm file. At run time, the property is set to bkNone during the component’s create event, but after that its properties are loaded in by the Reader and reset to bkFlat.
So, the TacLayout component should inherit from TsCustomPanel, where the properties are not published, and selectively publish the properties needed. If Bevelkind is not published, it will not be streamed in by the Reader and all’s well.
I’ll study which properties are needed for the TacLayout component and make a better one.May 26, 2020 at 4:54 pm #68878HeDiBoParticipantThis is the result:
unit acLayout; {$i sDefs.inc} interface uses System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, sPanel; type TacLayout = class(TsCustomPanel) public constructor Create(AOwner: TComponent); override; property DockManager; published property Align; property Anchors; property AutoSize; property Constraints; property UseDockManager default True; property DockSite; property DoubleBuffered; property DragCursor; property DragKind; property DragMode; property Enabled; property FullRepaint; property Locked; {$IFDEF D2010} property Padding; property ParentDoubleBuffered; property Touch; property VerticalAlignment; property OnAlignInsertBefore; property OnAlignPosition; property OnGesture; property OnMouseActivate; {$ENDIF} property ParentShowHint; property PopupMenu; property ShowHint; property TabOrder; property TabStop; property Visible; property OnCanResize; property OnClick; property OnConstrainedResize; property OnContextPopup; property OnDockDrop; property OnDockOver; property OnDblClick; property OnDragDrop; property OnDragOver; property OnEndDock; property OnEndDrag; property OnEnter; property OnExit; property OnGetSiteInfo; property OnMouseDown; property OnMouseMove; property OnMouseUp; property OnResize; property OnStartDock; property OnStartDrag; property OnUnDock; property OnMouseEnter; property OnMouseLeave; end; implementation { TacLayout } uses Forms; constructor TacLayout.Create(AOwner: TComponent); begin inherited; SkinData.SkinSection := 'TRANSPARENT'; BevelEdges := [beLeft, beTop, beRight, beBottom]; BevelInner := bvNone; BevelOuter := bvNone; BorderWidth := 0; BorderStyle := bsNone; Caption := ' '; ParentCtl3D := False; Ctl3D := False; {$IFDEF D2010} ShowCaption := False; {$ENDIF} {$IFDEF DELPHI7UP} ParentBackground := True; {$ENDIF} ParentFont := False; SideShadow.Mode := ssmNone; if csDesigning in ComponentState then BevelKind := bkFlat else BevelKind := bkNone; end; end.
Although the skin says TRANSPARENT the control is not really totally transparent. If you move a TacLayout on top of another control, it will still obscure the covered control.
What is needed here is a type of glass effect. I’m not sure how to accomplish that.
Serge, can you help me out?May 26, 2020 at 10:40 pm #68884SupportKeymasterHello, Dick
You can’t make a really transparent control in VCL, only emulation of transparency may be implemented.May 27, 2020 at 1:56 pm #68890HeDiBoParticipantHi Serge,
There is a reason why I called the component TacLayout. That would leave the possibility to include a TsLayout component in the package.
Are you willing to do so?May 27, 2020 at 3:12 pm #68891Stephane SenecalParticipantPersonally, I don’t see the difference between this TacLayout and a simple flat TsPanel.
Stephane Senecal
CIS Group
Delphi programmer since 2001May 27, 2020 at 9:07 pm #68892HeDiBoParticipantPersonally, I don’t see the difference between this TacLayout and a simple flat TsPanel.
There is no difference (yet). It is just an easy way: no hassle with setting SkinDate and other stuff, also the border at design time is handy (you don’t have to guess at design time where the panel is).
May 27, 2020 at 9:09 pm #68893SpeedTIParticipantExact!
Regards
Valdir Sola -
AuthorPosts
- You must be logged in to reply to this topic.