Board index » cppbuilder » TToolbar and TToolButton

TToolbar and TToolButton


2004-01-12 07:52:34 AM
cppbuilder85
Hi,
I want to create a TToolButton at runtime and add it to a TToolBar.
In the Help for TToolButton, it says to use the function SetToolBar, so I
wrote
TToolButton* btn = new TToolButton(this);
btn->SetToolBar(toolBar);
and I get error saying that SetToolBar is not accesible,
What's the right way to add a TToolButton to a TToolBar at runtime?
thanks,
/totte
 
 

Re:TToolbar and TToolButton

"Totte Karlsson" < XXXX@XXXXX.COM >wrote in message
Quote
I wrote

TToolButton* btn = new TToolButton(this);
btn->SetToolBar(toolBar);

and I get error saying that SetToolBar is not accesible
SetToolBar() is declared as 'protected' in TToolButton, you cannot call it
directly.
Quote
What's the right way to add a TToolButton to a TToolBar at runtime?
The only way I can to do it is to derive a new class from TToolButton and
add a new ToolBar property that calls the protected SetToolBar() method, ie:
class TMyToolButton : public TToolButton
{
public:
__fastcall TMyToolButton(TComponent *Owner);
__property TToolBar* ToolBar = {read=FToolBar, write=SetToolBar};
};
Then at runtime you can instantiate an instance of your descendant instead
of TToolButton directly and then set its ToolBar property:
TMyToolButton *btn = new TMyToolButton(this);
btn->ToolBar = toolBar;
Why the native TToolButton does not already declare such a property, I do
not know.
Gambit
 

Re:TToolbar and TToolButton

"Totte Karlsson" < XXXX@XXXXX.COM >wrote in message news:4001e217$ XXXX@XXXXX.COM ...
Quote
Hi,
I want to create a TToolButton at runtime and add it to a TToolBar.
Set the Parent property:
btn->Parent = toolBar;
todd
 

{smallsort}

Re:TToolbar and TToolButton

Thanks,
I got it working using the Parent property. Its weird that help lists the
SetToolBar function?
thanks
/totte
"Totte Karlsson" < XXXX@XXXXX.COM >wrote in message
Quote
Hi,
I want to create a TToolButton at runtime and add it to a TToolBar.
In the Help for TToolButton, it says to use the function SetToolBar, so I
wrote

TToolButton* btn = new TToolButton(this);
btn->SetToolBar(toolBar);

and I get error saying that SetToolBar is not accesible,

What's the right way to add a TToolButton to a TToolBar at runtime?

thanks,

/totte




 

Re:TToolbar and TToolButton

"Totte Karlsson" < XXXX@XXXXX.COM >wrote in message
Quote
Its weird that help lists the SetToolBar function?
Not really. It really is the function that controls placing the button into
the ToolBar. It is just that it is a private function that TToolBar calls
internally.
Gambit
 

Re:TToolbar and TToolButton

well, I just ment that it's not too much help, since it is private,
therefore, it should not be in the help file.. or they should say it's
private at least.
/tk
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Totte Karlsson" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Its weird that help lists the SetToolBar function?

Not really. It really is the function that controls placing the button
into
the ToolBar. It is just that it is a private function that TToolBar calls
internally.


Gambit