Solved

Using the TToolbar component

Posted on 1997-09-16
4
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:anilms
ID: 1345204
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
ID: 1345205
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
ID: 1345206
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
ID: 1345207
Thanks!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 85
Making delphi communicate with a c# service 16 124
Create a path if not exists 7 109
Get weeknumber and year from date 4 33
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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