1

I don't even know how to put this... I want to align my controls both horizontally and vertically. I have 3 controls aligned vertically (Top, Client, Bottom), and this group I want to align it horizontally to the left, and another identical group aligned to the right. Now I use TPanel to group those 3 controls, but this causes me some flicker when the controls are repainted (the panel is painted over the controls first, and then again the controls). Is there a way to group controls with something that has nothing to display, so I can just use the alignment ?

enter image description here

Just put these controls on the form, there is no need for code. Or use this .dfm. Then run the program and minimize the window. When you restore the window, sometime but not always, it will flicker with some black background before the controls are painted...

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 388
  ClientWidth = 623
  Color = clBtnFace
  DoubleBuffered = True
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -15
  Font.Name = 'Tahoma'
  Font.Style = []
  Menu = MainMenu1
  OldCreateOrder = False
  Position = poScreenCenter
  PixelsPerInch = 134
  TextHeight = 18
  object GroupPanel1: TPanel
    Left = 0
    Top = 0
    Width = 623
    Height = 388
    Align = alClient
    UseDockManager = False
    ParentBackground = False
    TabOrder = 0
    ExplicitLeft = 232
    ExplicitTop = 200
    ExplicitWidth = 100
    ExplicitHeight = 41
    object Splitter1: TSplitter
      Left = 313
      Top = 0
      Height = 388
      ExplicitLeft = 376
      ExplicitTop = 208
      ExplicitHeight = 100
    end
    object LeftPanel: TPanel
      Left = 0
      Top = 0
      Width = 313
      Height = 388
      Align = alLeft
      UseDockManager = False
      ParentBackground = False
      TabOrder = 0
      ExplicitHeight = 464
      object Memo1: TMemo
        Left = 0
        Top = 41
        Width = 313
        Height = 328
        Align = alClient
        Lines.Strings = (
          'Memo1')
        TabOrder = 0
        ExplicitLeft = -3
        ExplicitTop = 42
        ExplicitHeight = 343
      end
      object StatusBar1: TStatusBar
        Left = 0
        Top = 369
        Width = 313
        Height = 19
        Panels = <>
        SimplePanel = True
        SimpleText = 'StatusBar1'
        ExplicitLeft = 112
        ExplicitTop = 368
        ExplicitWidth = 0
      end
      object Panel1: TPanel
        Left = 0
        Top = 0
        Width = 313
        Height = 41
        Align = alTop
        TabOrder = 2
        ExplicitLeft = 32
        ExplicitTop = 8
        ExplicitWidth = 185
        object Button1: TButton
          Left = 8
          Top = 10
          Width = 75
          Height = 25
          Caption = 'Button1'
          TabOrder = 0
        end
        object Button2: TButton
          Left = 89
          Top = 10
          Width = 75
          Height = 25
          Caption = 'Button2'
          TabOrder = 1
        end
        object Button3: TButton
          Left = 170
          Top = 10
          Width = 75
          Height = 25
          Caption = 'Button3'
          TabOrder = 2
        end
      end
    end
    object RightPanel: TPanel
      Left = 316
      Top = 0
      Width = 307
      Height = 388
      Align = alClient
      UseDockManager = False
      ParentBackground = False
      TabOrder = 1
      ExplicitLeft = 319
      object Memo2: TMemo
        Left = 0
        Top = 41
        Width = 307
        Height = 328
        Align = alClient
        Lines.Strings = (
          'Memo1')
        TabOrder = 0
        ExplicitTop = 34
        ExplicitHeight = 343
      end
      object StatusBar2: TStatusBar
        Left = 0
        Top = 369
        Width = 307
        Height = 19
        Panels = <>
        SimplePanel = True
        SimpleText = 'StatusBar1'
        ExplicitLeft = 112
        ExplicitTop = 368
        ExplicitWidth = 0
      end
      object Panel2: TPanel
        Left = 0
        Top = 0
        Width = 307
        Height = 41
        Align = alTop
        TabOrder = 2
        ExplicitTop = 8
        object Button4: TButton
          Left = 8
          Top = 10
          Width = 75
          Height = 25
          Caption = 'Button1'
          TabOrder = 0
        end
        object Button5: TButton
          Left = 89
          Top = 10
          Width = 75
          Height = 25
          Caption = 'Button2'
          TabOrder = 1
        end
        object Button6: TButton
          Left = 170
          Top = 10
          Width = 75
          Height = 25
          Caption = 'Button3'
          TabOrder = 2
        end
      end
    end
  end
  object MainMenu1: TMainMenu
    Left = 528
    Top = 72
    object File1: TMenuItem
      Caption = 'File'
    end
    object View1: TMenuItem
      Caption = 'View'
    end
    object Options1: TMenuItem
      Caption = 'Options'
    end
    object Help1: TMenuItem
      Caption = 'Help'
    end
  end
end

I tested on Windows 10 and Delphi 10.3 Rio... In older versions of Delphi I haven't encountered this problem.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55

0 Answers0