The following information is related to Delphi7, all of which was previously on my old website.
EditCLX and the Delphi7 Online Help
http://www.techtricks.com/delphi/noclxhelp.php Removing CLX topics from the Delphi7 help systemEditDEMO: Using Dynamcially Created Actions with ActionBands
(Posted Dec. 2, 2002)
This demo illustrates how to use actions dynamically created at runtime on ActionBands and still allow for the streaming of ActionBand runtime customizations. The main issue is that actions used on ActionBands must be created prior to streaming any saved ActionBand configuration file. The demo dynamically creates an action when the form is created which you can place onto the TActionToolBar by clicking on the Customize button. When the application is restarted the new button will appear on the ActionBand and it will be properly linked to the dynamically created Action. This is a simple example using dynamically created actions which could be expanded upon to create a more useful real world application.
Download:
http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=19313 Runtime Action DemoEditDEMO: Skin your TMainMenu using ActionBands
(Posted Nov. 18, 2002)
{:alert:}%red%UPDATE: The download for this demo has been updated as of December 2, 2002 to provide better support for menu skinning. If you've already downloaded this demo please download the update as it fixes several issues.%%
This demo illustrates how you can use ActionBand menus to "skin" an existing TMainMenu component all without having to completely switch your application to use ActionBands. The demo includes the code necessary to dynamically build ActionBand menus that mirror your applications existing menus. The advanatage is that you can update the appearance of your application's menus without switching the entire application over to use either Actions or ActionBands. While the ActionBand components are required to render the menus using various styles, you continue to modify your existing TMainMenu during application development to add new functionality or change existing functionality. To skin your applications popup menus you can use the TActionPopupMenu included in the update below.
The code provided in this demo simply gives you a means to leverage the new menu styles included with ActionBands in a way the has the least impact to your code. Typically when a developer starts a new application is when they would decide to use ActionBands because prior to this demo it was unclear how to use ActionBands without making large scale changes to an existing application.
The Delphi IDE itself uses a similar technique to "skin" it's menus while maintaining full backwards OTA compatibility.
In order to skin your applications TMainMenu components use the following steps:
- Open your application in the IDE
- Select your applications main form (the one with your TMainMenu) and clear its Menu property and drop a TActionMainMenu and a TActionManager component onto the form
- Select the TActionManager and double click the ActionBars property in the Object Inspector
- Click the Add New button on the collection editor window and set the first item's ActionBar property to the TActionMainMenuBar
- You will need to copy the following methods from the demo and add them as methods to your form: TForm1.LoadMenu, TForm1.UpdateMainMenuBar
- On the TActionMainMenuBar assign the OnPopup and the OnExitMenuLoop events and copy the code from the corresponding events of the demo.
- From the demo copy the FNewMenuActions: TList data member and add it to the private section of your Form
- Add an OnCreate event to your form and copy the code from the demo's TForm1.FormCreate event to it
- Add an OnDestroy event to your form and copy the code from the demo's TForm1.FormDestroy event to it
At this point you should be able to run your application and use the new menu styles made possible by ActionBands. For additional control of menu colors try dropping one of the ColorMap components from the additional tab of the Component Palette and assigning it to your TActionMainMenuBar.ColorMap property. For a peek at some of the menu variations have a
http://homepages.borland.com/strefethen/root/ABSamples.htm look at this page.
Download:
http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=19272 ActionBand Skin DemoEditPATCH: Delphi 7.0 Unofficial ActionBands Update (All Languages)
Posted: November 1st, 2002
This is an unofficial (read unsupported) update of the ActionBands feature of Delphi 7.0 that addresses the items listed below. This patch will effect both end user applications that use ActionBands as well as the Delphi IDE itself since the menus in the IDE are ActionBand menus.
This update also incorporates the TActionPopupMenu component and will install it on the component palette so if you previously installed this component you should remove it before you apply this patch.
- Standard menu color scheme now correctly handles the flat menu style (see SPI_GETFLATMENU in MSDN).
- Fixed an issue regarding auto hotkey calculation.
- Fixed transparent painting problem for actionbands with background bitmaps.
- Fix an issue where the application hint wasn't being updated correctly.
- Fixed issues with TActionMainMenuBar not functioning correctly in MDI applications.
- Fixed issue with setting ActionBand popup menu colors correctly.
- Fixed F1 help on ActionBand menus.
- Fixed issue regarding ActionBand menus no longer respond to Ctrl-key combinations.
- Fixed problems related to positioning menus with Ctrl-arrow key combinations.
- Fixed menu items so they can be selected with the right mouse button.
- Fix to allow arrow keys to function within a menu even if the Alt key held down pressed.
- Fixed popup menu shadows not appearing on Windows 2000.
- Fixed Customize dialog to show actions from linked ActionLists correctly.
- Fixed TActionManager.AddSeparator method so separators get added correctly.
- Fixed a bug so that a submenus parent item is reselected if the mouse leaves the parent item but passes over the submenu before it closes.
- Improved the drawing of the XP style menu buttons.
- Fixed bug in Standard style menu button paint logic.
- Fixed problems with TCustomizeActionBars action so that it will work even when it is not in a TActionManager but it's ActionManager property is assigned.
- Fixed drawing problems with dropdown buttons on TActionToolbar for both XP and Standard styles
- Fixed AV dragging a category over a menu item and then over a TActionToolBar
Download:
http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=19151 Delphi 7.0 ActionBand PatchEditCOMPONENT: TActionPopupMenu (Delphi 7.0 only)
Posted: November 1st 2002
This component has since been included with the ActionBands update for D7. The update can be downloaded
http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=19151 here.
Delphi 7.0 did not ship with popup menu support for ActionBands and this component serves to compliment the menu functionality by implementing ActionBand style popup menus. TActionPopupMenu can be used as a replacement for TPopupMenu when a consistent menu style is desired. With this component and using ActionBands in Delphi 7 it is possible to develop applications that have a complete Microsoft Office XP menu style.
Download:
http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=18870 TActionPopupMenu!!!!FIX: ActionManager PrioritySchedule Property Editor Fix (Delphi 7.0)
Posted: September 19th 2002
In the shipping version of D7 there is a bug in the TValueListEditor which causes an access violation when attempting to invoke the property editor for the TActionManager.PrioritySchedule property. This fix is a package that replaces simply registers the standard string list property editor thereby avoiding the error.
Download:
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=18852 PrioritySchedule Property Editor FixEditPosted: September 4th 2002
This demo allows you to create custom color maps. Colormaps are components used in conjunction with ActionBands to control the appearance of ActionBands within your application. The demo provides a live preview of the colormap and allows for runtime customization of the colormap. Included with this demo is a TColorBox descendant called TColorChanger that has two additional properties which allow you to connect it to another component with a color property and change that color using the combobox.
Here is a screenshot which illustrates combinations of the two ActionBand menus styles provided by default with VCL with various colormaps applied.
The top row uses the XP Style menus and the bottom row is the Standard style menus.
NOTE: The two colormaps at the far right of the picture were built using this ActionBand ColorMap Creator.
Download:
http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=18801 ActionBand Colormap CreatorEditEXPERT: Customize the Delphi 7.0 Main Menu style (Delphi 7.0)
Posted: September 3rd, 2002
This expert is more for fun than anything, it demonstrates how you can change the style of the IDE's main menu. This is a simply expert that adds a menu item to the Tools menu which displays a dialog that allows you to modify some of the properties of the main menu including the style. Unfortunately, this won't effect the appearance of the right click popup menus used in the IDE only the main menu. Perhaps in the future the IDE will support customizations of the popup menus as well.
Installation Instructions
To install this package in Delphi 7.0 do the following:
- Unzip all files to the same directory.
- Start Delphi 7.0 and open the package IDEMenuCustomizer.dpk
- Click the Install button on the Package dialog to compile and install the package
You should now see a new menu item on the Tools menu called "Customize Menus". When you select this item you will see a dialog that allows you to change the main menu style as well as enable/disable the menu shadow.
Features ideas left for the user:Add an option to store the settings and apply them when the IDE is restarted.
Add an option to specify a color map for use with the main menu.
Download:
http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=18800 D7 Menu CustomizerEditFIX: Fix for MDI child window buttons on TActionMainMenuBar (Delphi 7.0)
Posted: April 27th, 2004
To fix the MDI child window buttons on TActionMainMenuBar open ActnMenus.pas and replace function CallWndHook with the following code:
function CallWndHook(Code: Integer; WParam: wParam; Msg: PCWPStruct): Longint; stdcall;
procedure UpdateMDIMenuButtons;
var
I: Integer;
Parent: THandle;
ParentForm: TWinControl;
Form: TCustomForm;
begin
Parent := GetParent(Msg.hwnd);
if Parent = 0 then exit;
ParentForm := FindControl(Parent);
for I := 0 to MenuList.Count - 1 do
begin
Form := GetParentForm(MenuList.MenusI);
if (Form = ParentForm) and
(MenuList.MenusI is TCustomActionMainMenuBar) then
begin
if (Msg.Message = WM_MDIDESTROY) and (Form is TForm) and
(TForm(Form).MDIChildCount = 1) then
with MenuList.MenusI as TCustomActionMainMenuBar do
MDIChildRestored
else
with MenuList.MenusI as TCustomActionMainMenuBar do
GetActiveMDIChild;
break;
end;
end;
end;
begin
if Code = HC_ACTION then
case Msg.message of
// Use of WM_SIZE is required for any Windows version except Themed XP
WM_MDIGETACTIVE, WM_SIZE,
WM_MDIDESTROY: UpdateMDIMenuButtons;
WM_ACTIVATE:
if ActiveMenu is TCustomActionPopupMenu then
ActiveMenu.CloseMenu;
WM_SETTINGCHANGE:
if Assigned(UpdateActnMenusProc) then
UpdateActnMenusProc;
end;
Result := CallNextHookEx(MenuCallWndHook, Code, WParam, Longint(Msg));
end;
Change the
maMinimize case as indicated below:
procedure TInternalMDIAction.ExecuteTarget(Target: TObject);
begin
case MDIAction of
maActivate: SendMessage(GetParent(Form.Handle), WM_MDIACTIVATE, Form.Handle, 0);
maClose: Form.Close;
maRestore: SendMessage(GetParent(Form.Handle), WM_MDIRESTORE, Form.Handle, 0);
// Fixed to minimize the form not close it
maMinimize: Form.WindowState := wsMinimized;
end;
end;
EditFIX: Fix for TActionMainMenuBar drawing on a form with a TXPManifest component
Posted: March 22nd, 2005
To fix the drawing of the first menu item on a form with a TXPManifest component and a background that's not clBtnFace open ActnMan.pas and replace the following function:
procedure TCustomActionControl.DrawBackground(var PaintRect: TRect);
const
BrushStyle: arrayBoolean of TBrushStyle = (bsSolid, bsClear);
var
ARect: TRect;
begin
if not Selected and Assigned(ActionBar) and Assigned(ActionClient) and
(ActionBar.ParentBackground = True) and
(not ActionBar.ActionClient.HasBackground or
(ActionBar.ActionClient.HasBackground and
not (ActionBar.ActionClient.BackgroundLayout in blLeftBanner, blRightBanner))) and
ThemeServices.ThemesEnabled and (Canvas.Brush.Color = ActionBar.ColorMap.Color) and
(csParentBackground in ControlStyle) then
begin
ARect := BoundsRect;
ThemeServices.DrawParentBackground(ActionBar.Handle, Canvas.Handle, nil, Transparent, @ARect);
Canvas.Font.Handle := 0; // Hack: reset the font because it gets destroyed
Canvas.Font.Assign(Font);
end
else
begin
if Canvas.Brush.Bitmap = nil then
Canvas.Brush.Style := BrushStyleFORMATTER ERROR (":" and "&" not supported in Page Names);
Canvas.FillRect(PaintRect);
end;
end;