Problem of RzSizePanel on right side with custom aligned panel (Align=clCustom)

Home Forums Konopka Signature VCL Controls (formerly Raize Components) Problem of RzSizePanel on right side with custom aligned panel (Align=clCustom)

Viewing 5 reply threads
  • Author
    Posts
    • #3498
      benok
      Participant

        Hi,

        I noticed a problem of the RzSizePanel using with a custom aligned panel. (Please see ani-gif below.)

        RzSizePanelProblem

        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.


        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

        view raw

        Unit1.dfm

        hosted with ❤ by GitHub


        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.

        view raw

        Unit1.pas

        hosted with ❤ by GitHub

        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.

         

      • #3509
        Ray Konopka
        Keymaster

          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

        • #3512
          benok
          Participant

            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.


            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

            view raw

            Unit1.dfm

            hosted with ❤ by GitHub


            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.

            view raw

            Unit1.pas

            hosted with ❤ by GitHub

            Is there any workaround?

          • #3514
            Ray Konopka
            Keymaster

              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

            • #3517
              benok
              Participant

                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  🙂

              • #3519
                benok
                Participant

                  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 🙂

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.