Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TToolBar Button Click Problem

Status
Not open for further replies.

ahhchu

Programmer
Sep 19, 2001
38
US
I am using the TToolBar control. I am creating it in code and do not have the control on my form at design time. I need to have a varying number of buttons, this may change during the execution of the program. I can cannot figure out which button is clicked. If I add the button at DESIGN TIME its simple. If I am adding a varying number of buttons how do I detect which one is being clicked. I know it must be easy but I cannot figure it out.

Thanks

 
I figured this out... Just override the the Click method of the TToolButton object. I created my own object from TToolButton and then overrode the Click method:

type
TMyToolButton = class (TToolButton)
private
// you could create other variable here that
// help you identify the button being clicked
ButtonId : integer;
procedure Click; override;
end;

implementation
//other code to get the Toolbar create and buttons created
..
..
procedure TMyToolButton.Click;
begin
ShowMessage ('clicked ' + IntToStr(ButtonId));
end;

The button is used in a toolbar that is totally created and populated in code. There are no GUI parts on the form. If ya tried to figure this out THANKS... hope it helps others

ahhchu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top