#1 2011-10-05 12:10:37

coblongpamor
Member
From: Bali-Indonesia
Registered: 2010-11-07
Posts: 130
Website

How to know Associated enum action of the TSynToolButton?

I try to use TSQLCustomToolBar like this:

...
...
TTestAction =
    (taTest1,taTest2);
...
...
FToolBar: TSQLCustomToolBar;
...
procedure ActionClick(Sender: TObject);
begin
    case TSynToolButton(Sender).Index of
        0:ShowMessage('Test -1');
        1:ShowMessage('Test -2');
    end;
end;
...
...

FToolBar.Init(self,TypeInfo(TTestAction),ActionClick,ImageList,'');
FToolBar.AddToolBar('Test')

this code is work as expected, but i want to use TTestAction in the case evaluate, something like:

    case TTestAction(Sender) of
        taTest1:ShowMessage('Test -1');
        taTest2:ShowMessage('Test -2');
    end;

how to use an associated action of TSynToolButton;
many thanks.

Offline

#2 2011-10-05 14:05:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: How to know Associated enum action of the TSynToolButton?

You can use:

case TTestAction((Sender as TSynToolButton).Tag) of
  taTest1: ....

See how the buttons are created in TSynToolBar.CreateToolButton() method of SQlite3Toolbar.pas.

Offline

#3 2011-10-05 14:24:27

coblongpamor
Member
From: Bali-Indonesia
Registered: 2010-11-07
Posts: 130
Website

Re: How to know Associated enum action of the TSynToolButton?

thank you ab.

Offline

Board footer

Powered by FluxBB