Switch menu for TB97 toolbars |
TB97 toolbars are grate! You can move them around on any side of the form, you can add persistence and next time you start the program they'll be there. However once you take them out of a docking holder and turn them off, they'll disappear forever. You need a way to put them back!
Usually, a menu to switch on and off will do the job. Here is the best method to implement it:
procedure TForm1.SwitchToolbar1Click(Sender: TObject);
begin
Toolbar971.Visible:=not SwitchToolbar1.Check;
end;
procedure TForm1.Toolbar971VisibleChanged(Sender: TObject);
begin
SwitchToolbar1.Check:=Toolbar971.Visible;
end;
The OnClick method of the menu will show or hide the toolbar according to its checked status. Then the OnVisibleChange method of the toolbar will update the checked status of the menu. Don't forget to make the Checked property of the menu persistent!
A good idea is to group all switch menu items for all toolbars in a TOOLBARS submenu, then give the toolbar captions the same name as the corresponding menu items.
FormStorage from the RX freeware pack of components is great, but using it in an ActiveX Active-Form rise a small problem: it does not save the form and other contained properties! The reason is that the form never close. There is however an easy fix for this:
Override in the Public section of the form the BeforeDestruction method, and close the form there:
type
TXMyForm = class(TActiveForm, IXMyForm)
...
public
...
procedure BeforeDestruction; override;
...
end;
procedure TXSabreX.BeforeDestruction;
begin
inherited;
Close;
end;
procedure TXSabreX.BeforeDestruction;
begin
inherited;
IniSaveToolbarPositions(Self, FormStorage1.IniFileName);
Close;
end;
|
|
Horia Tudosie Computer Consulting horiatu@pathcom.com Go to my Home Page |