Solved

Using the TToolbar component

Posted on 1997-09-16
4
144 Views
Last Modified: 2010-08-05
Is it possible to add toolbar buttons at run-time? Sample code would be extremely helpful.
0
Comment
Question by:khenr29j
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:anilms
Comment Utility
Yes, it is possible to add buttons at run time. Do the following:

1. Create an application. Drop a button onto the form. Drop a TToolbar also onto the form.

2. In the variabled section, add ButtonNew as a TButton variable.

3. For Button1 click event, add the event hadnling code.

4. The whole program should be as follows :

----------------------------
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ToolBar1: TToolBar;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ButtonNew:TButton;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
      {Creating a New Button}
      ButtonNew := TButton.Create(ToolBar1);
      {Setting the parent to the ToolBar}
      ButtonNew.Parent := ToolBar1;
end;

end.

0
 

Author Comment

by:khenr29j
Comment Utility
I would like to add TToolButtons to it, not normal controls. TToolButtons can be made flat-looking, a la Netscape.
0
 
LVL 1

Accepted Solution

by:
anilms earned 50 total points
Comment Utility
Instead of the TButton component, you can use the TSpeedButton component and set the Flat property to true on those buttons. This will work well.
0
 

Author Comment

by:khenr29j
Comment Utility
Thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now