Solved

Using the TToolbar component

Posted on 1997-09-16
4
155 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 68
can't find the executable in Simulator 1 90
Delphi inherited method 6 70
Why  'Host Connection unavailable/Socket Error #113 No route to host' 6 42
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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