Home › Forums › Konopka Signature VCL Controls (formerly Raize Components) › Problem of RzSizePanel on right side with custom aligned panel (Align=clCustom)
Tagged: RzSizePanel alignment alCustom
- This topic has 5 replies, 2 voices, and was last updated 2023-05-17 at 1:01 am by benok.
-
AuthorPosts
-
-
May 8, 2023 at 8:06 am #3498
Hi,
I noticed a problem of the RzSizePanel using with a custom aligned panel. (Please see ani-gif below.)
Left aligned size panel works as expected, but right aligned one doesn’t.
It seems there’s some problem with the layout code.
(It’s my first time using alCustom, the problem might be brought by my code. It seems to work, but I don’t have confidence.)
I uploaded the above sample to my gist below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
— 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 );
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. p.s.(1)
My production code which I noticed this problem is MDI main form.
I made and tested both SDI/MDI samples, and the RzSizePanel’s behaviors are the same.
p.s.(2)
Is there any document or link to set up debug environment of KSVCL components ?I want to debug this myself, but it’s a bit tricky to set up.
-
May 8, 2023 at 8:10 am #3509
Unfortunately, the animated GIF is not animating, so I’m not sure what behavior you are seeing. As for debugging the components, you can add the source directory for the components to your Project Search Path. Then when you rebuild your project, the KSVC source will get recompiled as well and then you’ll be able to step through the code.
Ray
-
May 9, 2023 at 11:31 pm #3512
Thank you for commenting about debugging.
I want to make time to debug, but I think it’s very difficult this week…
I added the animation gif to the gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
— 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 );
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. Is there any workaround?
-
May 10, 2023 at 12:33 am #3514
So, the TRzSizePanel is technically working as designed. The TRzCustomSizePanel.GetParentWorkingRect method looks at the various controls (and child controls) on the form to determine the range of the sizing bar. In your particular example, the right edge of the Close button is restricting the range of the right SizePanel.
If you were building an SDI application, then I would suggest dropping a Panel into the main client area, setting the Align property to alClient, and then dropping your panel with the Close button onto the client panel and set the Align property to alTop. Then the size panel would function as you expect. However, that approach does not work with an MDI application.
As an alternative, you could align your close panel to be alTop, which would allow the size panel to work properly, but then you do not get the visual layout you are looking for.
Another option would be to modify the TRzCustomSizePanel.GetParentWorkingRect method and comment out the alCustom case label in the middle of the method. This would eliminate the range check for the alCustom panel and then the size panel would be able to be dragged over the sub-panel.
Ray
-
May 10, 2023 at 5:43 am #3517
Thank you for your advice.
My production app is MDI base and it’s important for me to use this layout, so I’ll try the latter suggestion next week.
Another option would be to modify the TRzCustomSizePanel.GetParentWorkingRect method and comment out the alCustom case label in the middle of the method. This would eliminate the range check for the alCustom panel and then the size panel would be able to be dragged over the sub-panel.
I’m happy to see a solution in sight 🙂
-
May 17, 2023 at 1:01 am #3519
Sorry for my late reply,
I confirmed the patch fixes the problem as you suggested.
https://gist.github.com/benok/d88edc97629716173b4cef598a54498d#file-rzsplit_workaround-patch
Thank you again for your suggestion.
You saved my time 🙂
-
-
AuthorPosts
- You must be logged in to reply to this topic.