Skip to content

Instantly share code, notes, and snippets.

@benok
Last active May 29, 2023 04:47
Show Gist options
  • Save benok/d88edc97629716173b4cef598a54498d to your computer and use it in GitHub Desktop.
Save benok/d88edc97629716173b4cef598a54498d to your computer and use it in GitHub Desktop.
Problem of RzSizePanel on right side with custom aligned panel (Align=clCustom)
program RzSizePanelTest;
uses
Vcl.Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
--- C:/Users/Public/Documents/Embarcadero/Studio/21.0/CatalogRepository/KonopkaControls-270-6.2.3/Source_Copy/RzSplit.pas Tue Jun 9 03:51:42 2020
+++ C:/Users/Public/Documents/Embarcadero/Studio/21.0/CatalogRepository/KonopkaControls-270-6.2.3/Source/RzSplit.pas Wed May 17 13:45:14 2023
@@ -4013,15 +4013,15 @@
alLeft:
Inc( Result.Left, Parent.Controls[ I ].Width );
alRight:
Dec( Result.Right, Parent.Controls[ I ].Width );
- alNone, alCustom:
+ alNone{, alCustom}:
begin
case FSide of
sdTop:
Inc( Result.Top, Parent.Controls[ I ].Height );
sdBottom:
Dec( Result.Bottom, Parent.Controls[ I ].Height );
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 636
ClientWidth = 1286
Color = clAppWorkSpace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object RzStatusBar1: TRzStatusBar
Left = 0
Top = 617
Width = 1286
Height = 19
BorderInner = fsNone
BorderOuter = fsNone
BorderSides = [sdLeft, sdTop, sdRight, sdBottom]
BorderWidth = 0
TabOrder = 0
VisualStyle = vsGradient
end
object RzToolbar1: TRzToolbar
Left = 0
Top = 0
Width = 1286
Height = 29
BorderInner = fsNone
BorderOuter = fsGroove
BorderSides = [sdTop]
BorderWidth = 0
TabOrder = 1
VisualStyle = vsGradient
end
object RzSizePanel1: TRzSizePanel
Left = 0
Top = 29
Width = 202
Height = 588
HotSpotVisible = True
SizeBarWidth = 7
TabOrder = 2
object btnShowInfo: TButton
Left = 16
Top = 24
Width = 161
Height = 25
Caption = 'Show Info'
TabOrder = 0
OnClick = btnShowInfoClick
end
end
object RzSizePanel2: TRzSizePanel
Left = 1036
Top = 29
Width = 250
Height = 588
Align = alRight
HotSpotVisible = True
SizeBarWidth = 7
TabOrder = 3
end
object pnlInfo: TRzPanel
Left = 216
Top = 35
Width = 809
Height = 43
Align = alCustom
BorderOuter = fsNone
Color = clInfoBk
TabOrder = 4
Visible = False
object lblInfo: TLabel
Left = 16
Top = 16
Width = 74
Height = 13
Caption = 'Some Info Text'
end
object btnClose: TRzButton
AlignWithMargins = True
Left = 726
Top = 8
Height = 27
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Align = alRight
Caption = 'Close'
TabOrder = 0
OnClick = btnCloseClick
end
end
end
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzButton, RzPanel, RzSplit, Vcl.ExtCtrls,
Vcl.StdCtrls;
type
TForm1 = class(TForm)
RzStatusBar1: TRzStatusBar;
RzToolbar1: TRzToolbar;
RzSizePanel1: TRzSizePanel;
RzSizePanel2: TRzSizePanel;
pnlInfo: TRzPanel;
btnClose: TRzButton;
btnShowInfo: TButton;
lblInfo: TLabel;
procedure btnCloseClick(Sender: TObject);
procedure btnShowInfoClick(Sender: TObject);
private
protected
procedure CustomAlignPosition(Control: TControl; var NewLeft, NewTop, NewWidth, NewHeight: Integer;
var AlignRect: TRect; AlignInfo: TAlignInfo); override;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.CustomAlignPosition(Control: TControl; var NewLeft, NewTop,
NewWidth, NewHeight: Integer; var AlignRect: TRect; AlignInfo: TAlignInfo);
begin
inherited;
if (Control = pnlInfo) and
pnlInfo.Visible then
begin
// Set on Top of the AlignRect
NewLeft := AlignRect.Left;
NewTop := AlignRect.Top;
NewWidth := AlignRect.Width;
NewHeight := pnlInfo.Height;
// Decrease AlignRect Top Area
AlignRect.Top := NewTop + NewHeight;
end;
end;
procedure TForm1.btnShowInfoClick(Sender: TObject);
begin
pnlInfo.Show;
end;
procedure TForm1.btnCloseClick(Sender: TObject);
begin
pnlInfo.Hide;
end;
end.
@benok
Copy link
Author

benok commented May 17, 2023

I confirmed the patch fixes this problem as Ray suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment