1

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!

9
  • 1
    If you really want a nice toolbar, forget Coolbar, and get something else. Anything. If your app is opensource there's toolbar2000+SpTBX. If it's closed source, a license for toolbar2000 is quite cheap.
    – Warren P
    Jul 1, 2011 at 13:49
  • Thanks, but I would like to use TCoolBar
    – maxfax
    Jul 1, 2011 at 15:32
  • Since you apparently want your toolbar to look like uTorrent's, could you please post a picture of that program so those who are unfamiliar with it can see what you're talking about? Jul 1, 2011 at 16:41
  • 1
    I would like my Ford Focus to look like a Porsche. :-)
    – Warren P
    Jul 1, 2011 at 17:00
  • but how did they make a gradient like in CoolBar?
    – maxfax
    Jul 1, 2011 at 20:45

2 Answers 2

4

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
3
  • Will I have an effect like in uTorrent (please look at it's CoolBar)?
    – maxfax
    Jul 1, 2011 at 13:20
  • I need to have all controls on CoolBar
    – maxfax
    Jul 1, 2011 at 13:24
  • @maxfax - sorry but that wasn't clear to me in your question. Anyway, your answer seems to have been solved already so there's no point in trying to adjust this answer. Jul 1, 2011 at 21:44
2

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

5
  • This CoolBar behaves stupidly with FixedSize. Bands have a width like 1200px!!! I can not align bands. I resize bands -> then they get mixed. I hate this coolbar...If it would be a man I would kill him :)
    – maxfax
    Jul 1, 2011 at 20:05
  • I think you are right that this component is hard to handle (and that's mildly). Though you should not get so emotional. Did you get the comment of Sertac Akyuz about uTorrent?
    – NGLN
    Jul 1, 2011 at 20:28
  • No? Where can I get? How did they can do it?
    – maxfax
    Jul 1, 2011 at 20:34
  • @maxfax It's the latest comment to this question.
    – NGLN
    Jul 1, 2011 at 20:41
  • I am sorry, I have looked all and have not seen :)
    – maxfax
    Jul 1, 2011 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.