Tips and Frequently Asked Questions
Toggle between TMS Office hints and regular hints
You can easily toggle in the application between using TMS Office hints and regular hints via the code:
begin
if NormalHints.Checked then
HintWindowClass := THintWindow
else
HintWindowClass := TAdvOfficeHintWindow;
end;
How to use TAdvOfficeHint for controls that do not have an OfficeHint property
You can use TAdvOfficeHint also for controls that do not have an OfficeHint property, for example in our
HTML controls.
By implementing the event OnBeforeShowHint, you can control the information for the hint also for controls that do not have an OfficeHint property, only a hint property. This way, you do not need to use THTMLHint. TAdvOfficeHint can also display HTML formatted text.
Changing font and font size in TAdvMenuOfficeStyler does not work
To use a custom font for the menu you have to change in the TadvMenuOfficeStyler the property UseSystemFont = false. Otherwise, the menu styler forces the font to the font as defined in the operating system.
Programmatically make toolbar floating and dock toolbar
To make a toolbar on a TAdvDockPanel floating use:
AdvToolBar.SetToolBarFloating(point(X,Y));
with X,Y the coordinates where to put the floating toolbar.
To dock the toolbar back to the TAdvDockPanel, use:
AdvToolBar.ManualDock(AdvDockPanel);
Using a toolbar customizer
Drop a TAdvToolBar and TAdvToolBarCustomizer on the form
Assign the AdvToolBar to AdvToolBarCustomizer.AdvToolBar. Click the toolbar right-handle and the toolbar customizer dialog will automatically appear.
Inserting, updating a menu item at runtime
When inserting or updating a menu item at runtime, do this with BeginUpdate / EndUpdate calls. This is a requirement due to an optimization for visual updates when the menu stylers are used. Following sample code snippet shows how to add a new menu item at runtime:
var
mnu: TMenuItem;
begin
AdvMainMenu1.BeginUpdate;
mnu := TMenuItem.Create(self);
mnu.Caption := 'New item';
AdvMainMenu1.Items[1].Insert(0,mnu);
AdvMainMenu1.EndUpdate;
end;
Changing the display time of TAdvOfficeHint
The hint time is controlled the same way as regular hints in Delphi.
This is set with :
Application.HintHidePause
Application.HintPause
Programmatically adding items to the application menu
This code snippet shows how menu items and submenu items can be programmatically added to the application menu, TAdvPreviewMenu:
begin
AdvPreviewMenu1.MenuItems.BeginUpdate;
with AdvPreviewMenu1.MenuItems.Add do
begin
Caption := 'Mainitem1';
SubMenuCaption := 'Sub menu caption1';
with SubItems.Add do
begin
Title := 'Subitem1';
Notes.Text := 'This is an additional note';
end;
end;
with AdvPreviewMenu1.MenuItems.Add do
begin
Caption := 'Mainitem2';
SubMenuCaption := 'Sub menu caption2';
with SubItems.Add do
begin
Title := 'Subitem2';
Notes.Text := 'This is an additional note';
end;
end;
AdvPreviewMenu1.MenuItems.EndUpdate;
end;
Programmatically adding page, toolbar and button to the ribbon
Following code snippet illustrates how you can add a new page with a new toolbar and a new button via code to the Office 2007 ribbon control. To test this, drop a TAdvToolBarPager on the form and add following code:
var
AdvPage: TAdvPage;
AdvToolBar: TAdvToolBar;
AdvGlowButton: TAdvGlowButton;
begin
AdvPage := TAdvPage.Create(self);
AdvPage.Caption := 'New page';
AdvPage.AdvToolBarPager := AdvToolBarPager1;
AdvToolBarPager1.ActivePageIndex := AdvToolBarPager1.AdvPageCount - 1;
AdvToolBar := TAdvToolBar.Create(self);
AdvToolBar.Parent := AdvPage;
AdvToolBar.Caption := 'New toolbar';
AdvGlowButton := TAdvGlowButton.Create(Self);
AdvGlowButton.Parent := AdvToolBar;
AdvGlowButton.Caption := 'New Button';
AdvGlowButton.ShowCaption := true;
end;
Providing an Office 2007 type hint for any control
The TMS components that have built-in support for Office 2007 type hints expose the property OfficeHint with which the hint title, notes, picture and help line can be set. If you want to use an Office 2007 for another standard VCL component or other 3rd party component, you can use the event AdvOfficeHint.OnBeforeShowHint. This sample demonstrates how this can be done. Via the event handler, an Office 2007 hint is set for a TAdvSmoothButton:
procedure TForm1.AdvOfficeHint1BeforeShowHint(Sender: TObject;
AControl: TControl; AHintInfo: TAdvHintInfo; var UseOfficeHint: Boolean);
begin
if AControl = AdvSmoothButton1 then
begin
UseOfficeHint := true; // set true to tell the TAdvOfficeHint it should display the hint in Office 2007 style
AHintInfo.Title := 'Button title';
AHintInfo.Notes.Text := AControl.Hint;
AHintInfo.Picture.LoadFromFile(''); // optionally add a hint picture here from file, resource or stream
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// set the standard Hint to make sure it shows, this is reused as hint notes
AdvSmoothButton1.Hint := 'Smooth button hint';
end;
Starting with TMS ToolBars & Menus to create Office 2003 style applications
- Step 1: Drop one or more TAdvDockPanel components on the form. With the property Align, select on which side of the form the toolbars will be dockable.
- Step 2: Drop a TAdvToolBarOfficeStyler component on the form and assign it to AdvDockPanel.ToolBarStyler
- Step 3: Drop one or more TAdvToolBar components on the TAdvDockPanel. Assign the TAdvToolBarOfficeStyler to the TAdvToolBar.ToolBarStyler property
- Step 4: Right-click the TAdvToolBar and choose to add a button, menubutton or separator or drop any control on the TAdvToolBar
Using the TMS TAdvMenus with the TAdvToolBar
- Step 1: Drop a TAdvMainMenu on the form and use the design-time editor to define the menu. Drop a TAdvMenuStyler on the form and assign it to TAdvToolBarStyler.AdvMenuStyler
- Step 2: Remove the Form.Menu property
- Step 3: Assign the TAdvMainMenu to TAdvToolBar.Menu
Starting with TMS ToolBars & Menus to create Office 2007 style applications
Choose File, New, Other, TMS Wizard, TMS ToolBar Application wizard : A new application with TAdvToolBarPager will be created
Handling shortcuts
As menus are assigned to a toolbar and not to a form and the form is responsible for shortcut handling, the TAdvToolBar's shortcuts can be handled by adding the following code in the form's OnShortCut event:
procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
Handled := AdvToolBar1.IsShortCut(Msg);
end;
Upgrading from TAdvToolBar v1.x
Make sure to FIRST reopen ALL form files in your application that use the TAdvToolBar and/or TAdvToolBar styler components, ignore all property errors upon opening the forms and save the form files before rebuilding your application.
Using menu items with Notes
A menu item with a Notes text can be setup using \n to separate lines, ie
MenuItem.Caption := 'MenuCaption\nLine 1 of the notes text\nLine 2 of the notes text';