khenr29j
asked on
Using the TToolbar component
Is it possible to add toolbar buttons at run-time? Sample code would be extremely helpful.
ASKER
I would like to add TToolButtons to it, not normal controls. TToolButtons can be made flat-looking, a la Netscape.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
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
begin
{Creating a New Button}
ButtonNew := TButton.Create(ToolBar1);
{Setting the parent to the ToolBar}
ButtonNew.Parent := ToolBar1;
end;
end.