德尔福:TCoolBar + TToolBar+TEdit+TCheckBox

发布于 2024-11-18 09:11:54 字数 204 浏览 2 评论 0原文

如何将 ToolBar 放在 CoolBar 的左侧,Edit - 居中,CheckBox - 右侧?

我试图在 2 小时内完成此操作,但我不能:( 控件在其他控件后面,或者宽度与 CoolBar 一样。愚蠢的事情:)

在此输入图像描述

谢谢!

How can I put ToolBar on the left side of CoolBar, Edit - center, CheckBox - on the right?

I am trying to do this during 2 hours and I can not:( Controls are behind others, or have a width as CoolBar. Stupid things :)

enter image description here

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青柠芒果 2024-11-25 09:11:54

您的设计外观的屏幕截图会有所帮助,但将它们放在单独的 TPanels 上可以让您更自由地表达。

.pas 文件

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ToolWin, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    CoolBar1: TCoolBar;
    Panel2: TPanel;
    tlb1: TToolBar;
    Edit1: TEdit;
    CheckBox1: TCheckBox;
    btnToolbar: TToolButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.

.dfm 文件

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 348
  ClientWidth = 643
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 348
    Height = 348
    Align = alLeft
    Caption = 'Panel1'
    TabOrder = 0
    ExplicitLeft = 458
    ExplicitHeight = 185
    object CoolBar1: TCoolBar
      Left = 1
      Top = 1
      Width = 346
      Height = 75
      Bands = <>
      ExplicitLeft = 96
      ExplicitTop = 136
      ExplicitWidth = 150
    end
  end
  object Panel2: TPanel
    Left = 348
    Top = 0
    Width = 295
    Height = 348
    Align = alClient
    Caption = 'Panel2'
    TabOrder = 1
    ExplicitLeft = 432
    ExplicitTop = 128
    ExplicitWidth = 185
    ExplicitHeight = 41
    object tlb1: TToolBar
      Left = 1
      Top = 1
      Width = 293
      Height = 29
      Caption = 'tlb1'
      TabOrder = 0
      ExplicitLeft = 72
      ExplicitTop = 160
      ExplicitWidth = 150
      object btnToolbar: TToolButton
        Left = 0
        Top = 0
        Caption = 'btnToolbar'
        ImageIndex = 0
      end
    end
    object CheckBox1: TCheckBox
      Left = 80
      Top = 166
      Width = 97
      Height = 17
      Caption = 'CheckBox1'
      TabOrder = 1
    end
  end
  object Edit1: TEdit
    Left = 280
    Top = 164
    Width = 121
    Height = 21
    TabOrder = 2
    Text = 'Edit1'
  end
end

A screenshot of what your design should look like would help but placing them on seperate TPanels gives you more freedom sort to speak.

.pas File

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ToolWin, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    CoolBar1: TCoolBar;
    Panel2: TPanel;
    tlb1: TToolBar;
    Edit1: TEdit;
    CheckBox1: TCheckBox;
    btnToolbar: TToolButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.

.dfm File

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 348
  ClientWidth = 643
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 348
    Height = 348
    Align = alLeft
    Caption = 'Panel1'
    TabOrder = 0
    ExplicitLeft = 458
    ExplicitHeight = 185
    object CoolBar1: TCoolBar
      Left = 1
      Top = 1
      Width = 346
      Height = 75
      Bands = <>
      ExplicitLeft = 96
      ExplicitTop = 136
      ExplicitWidth = 150
    end
  end
  object Panel2: TPanel
    Left = 348
    Top = 0
    Width = 295
    Height = 348
    Align = alClient
    Caption = 'Panel2'
    TabOrder = 1
    ExplicitLeft = 432
    ExplicitTop = 128
    ExplicitWidth = 185
    ExplicitHeight = 41
    object tlb1: TToolBar
      Left = 1
      Top = 1
      Width = 293
      Height = 29
      Caption = 'tlb1'
      TabOrder = 0
      ExplicitLeft = 72
      ExplicitTop = 160
      ExplicitWidth = 150
      object btnToolbar: TToolButton
        Left = 0
        Top = 0
        Caption = 'btnToolbar'
        ImageIndex = 0
      end
    end
    object CheckBox1: TCheckBox
      Left = 80
      Top = 166
      Width = 97
      Height = 17
      Caption = 'CheckBox1'
      TabOrder = 1
    end
  end
  object Edit1: TEdit
    Left = 280
    Top = 164
    Width = 121
    Height = 21
    TabOrder = 2
    Text = 'Edit1'
  end
end
╄→承喏 2024-11-25 09:11:54

我认为您正在寻找 CoolBand 的 Break 属性:

Break 属性 (TCoolBand) 导致带区开始新行。如果 Break 为 true(默认值),则该区域将在 TCoolBar 控件的左侧开始一个新行。如果 Break 为 false,则该带将继续与其前一个带相同的线路。

因此,获取图像布局的步骤:

  • 在表单上放置一个 CoolBar(默认顶部对齐)并给它一些额外的高度,
  • 设置固定顺序为 True,
    向 CoolBar 添加一个 ToolBar、一个 Edit 和一个 CheckBox,
  • 打开 Bands 集合编辑器,
  • 将每个 CoolBand 集合项的 Break 属性设置为 False,
  • 拖动独立 CoolBand 的宽度(或设置每个 CoolBand 的 width 属性),
  • 设置 CoolBar .AutoSize 为 True。

在此处输入图像描述

I think you are searching for the Break property of a CoolBand:

Break property (TCoolBand) causes the band to start on a new line. If Break is true (the default), the band starts a new line at the left side of the TCoolBar control. If Break is false, the band continues on the same line as its predecessor.

So the steps to get the layout of your image:

  • Put a CoolBar on the form (default top aligned) and give it some extra height,
  • Set FixedOrder to True,
    Add a ToolBar, an Edit and a CheckBox to the CoolBar,
  • Open the bands collection editor,
  • Set of every CoolBand collection item the Break property to False,
  • Drag the width of the independent CoolBands (or set the width property of each),
  • Set CoolBar.AutoSize to True.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文