TAppBar Class v.1.4 for Delphi 2.0 and 3.0 Copyright (c) 1997/98 Paolo Giacomuzzi e-mail: paolo.giacomuzzi@usa.net http://www.geocities.com/SiliconValley/9486 ------------------------------------------- PURPOSE The TAppBar class is a TForm derived class, that lets your form to behave like an Application Desktop Toolbar (i.e. to dock on the edges of the screen like the Windows 95/NT Taskbar). "An application desktop toolbar (or an appbar for short) is a window that attaches itself to an edge of your screen. (The shell’s taskbar window is a well-known example of an appbar). Though appbars are usually docked on an edge of the user's screen, they also can float. To make room for an appbar that's docked, the Windows 95/NT shell shrinks the size of the screen's workarea. The workarea is the portion of the screen that is not occupied by any appbars. Whenever the user maximizes a window, the system ensures that the window fills the workarea, not the full screen. If an appbar is docked on the edge of the screen, moved from one edge of the screen to another, or removed from an edge of the screen, the system automatically resizes and repositions any maximized windows so that they always fill the workarea completely. In addition, when the upper-left corner of the workarea changes, the system shifts all the application windows on the screen so that they always maintain their relative distance from that corner." (J. Richter, 'Extend the Windows 95 Shell with Application Desktop Toolbars', MSDN) USAGE To add appbar behavior to your application, just derive your main form from TAppBar, as shown in the DEMOAPP.DPR sample. Then, use the following properties and methods to customize the appbar appearance, position, size, and so on. PROPERTIES * AlwaysOnTop : Boolean Always-On-Top On/Off. If it is True, the appbar is always on top of all other windows. Recommended if AutoHide is True. * AutoHide : Boolean Auto-hide On/Off. If it is True, the appbar hides itself when focus is lost (just like the shell's taskbar). * Edge : TAppBarEdge Edge to dock on. It can assume one of the following values: abeLeft, abeTop, abeRight, abeBottom, abeUnknown, abeFloat. * Flags : TAppBarFlags Allowed dockable edges. It is a set of the following values: abfAllowLeft, abfAllowTop, abfAllowRight, abfAllowBottom, abfAllowFloat. * HorzSizeInc : Integer Horizontal increment when window is resized. A value of zero prevents the appbar to be resized left or right. * VertSizeInc : Integer Vertical increment when window is resized. A value of zero prevents the appbar to be resized top or bottom. * HorzDockSize : Integer AppBar height when docked left or right. * VertDockSize : Integer AppBar width when docked top or bottom. * FloatLeft : Integer * FloatTop : Integer * FloatRight : Integer * FloatBottom : Integer Coordinates of the window when the appbar is floating. * MinWidth : Integer Min allowed width when the appbar is floating. * MinHeight : Integer Min allowed height when the appbar is floating. * MaxWidth : Integer Max allowed width when the appbar is floating. * MaxHeight : Integer Max allowed height when the appbar is floating. * MinHorzDockSize : Integer Min allowed height when the appbar is docked horizontally. * MinVertDockSize : Integer Min allowd width when the appbar is docked vertically. * MaxHorzDockSize : Integer Max allowed height when the appbar is docked horizontally. * MaxVertDockSize : Integer Max allowed width when the appbar is docked vertically. * TaskEntry : TAppBarTaskEntry AppBar behavior in the Windows Taskbar. It can assume one of the following values: abtShow - the Taskbar entry is always shown abtHide - the Taskbar entry is never shown abtFloatDependent - the Taskbar entry is shown only when the appbar is floating * SlideEffect : Boolean When in auto-hide state, if it is True, the appbar slides in and out the screen. Otherwise the appbar pops in and out without animation. This property is ignored if the 'Show window contents while dragging' option is unchecked in the Control Panel. * SlideTime : Integer Amount of time (in milliseconds) for the appbar window to slide in or out of the screen. * RootKey : Integer RootKey in the registry where settings should be loaded/saved. The default root key is HKEY_CURRENT_USER. * KeyName : String KeyName in the registry where settings should be loaded/saved. The default key name is 'Software\AppBar\1.4\Delphi'. METHODS * UpdateBar Forces the appbar's visual appearance to match its internal state. Call this method after changing one or more properties. * LoadSettings Loads settings from the registry at RootKey and KeyName location. Returns TRUE if the settings are available, else FALSE. * SaveSettings Saves settings into the registry at RootKey and KeyName location. Returns TRUE if succeeded, else FALSE EVENTS (overridable functions) * procedure OnAppBarStateChange (bProposed : Boolean; abEdgeProposed : TAppBarEdge); virtual; Called when the appbar's state changes. Using this notification, it is possible to be notified when the appbar is going to change its state. If bProposed is True, the appbar is being repositioned on an edge but not yet docked. If bProposed is False, the appbar is definitively docked on a new edge. The abEdgeProposed argument indicates the edge the appbar is being docked. * procedure OnAppBarForcedToDocked; virtual; Called if the user attempts to dock an autohide appbar on an edge that already contains an autohide appbar. * procedure OnABNFullScreenApp (bOpen : Boolean); virtual; Called when a fullscreen application is opened or closed. The bOpen argument contains True if a fullscreen window is opening and False if one is closing. * procedure OnABNPosChanged; virtual; Called when any appbar alters its size. This notification is also sent when an appbar is removed, and when the shell's taskbar is in autohide mode and the user causes it to slide on or off the screen. * procedure OnABNWindowArrange (bBeginning : Boolean); virtual; Called when the user chooses either the cascade, tile horizontally, or tile vertically options from the shell's taskbar. This notification is sent to each appbar twice: the first time when the system is about to reposition all the windows (the bBeginning argument contains True), and the second time after that all the windows have been moved (the bBeginning argument contains False). DISCLAIMER THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. Because of the various software environments into which this class may be used, NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. Good data processing procedure dictates that any program based on this class be thoroughly tested with non-critical data before relying on it. THE USER MUST ASSUME THE ENTIRE RISK OF USING THE TAPPBAR CLASS. HISTORY * 1.0 - First implementation. * 1.1 - Added 'DemoApp.dpr' sample application and related files. Extended TAppBarFlags from [abfAllowLeftRight, abfAllowTopBottom, abfAllowFloat] to [abfAllowLeft, abfAllowTop, abfAllowRight, abfAllowBottom, abfAllowFloat]. * 1.2 - Fixed an incorrect window style modification if the appbar was dragged near an edge of the screen. Fixed an incorrect resizing of the window when the appbar was restored from a docked state to the floating state. * 1.3 - Added TaskEntry property. Fixed an occasional Access Violation, due to Boolean and LongBool different memory size. Removed the Maximize, Minimize and Restore items in the system menu. * 1.4 - The FloatRect property was replaced by the FloatLeft, FloatTop, FloatRight and FloatBottom properties. The DockDims property was replaced by the HorzDockSize and VertDockSize properties, so that the height and width of the appbar are mantained if you move it respectively from top to bottom or viceversa, and from left to right or viceversa. The TAppBarSettings record now contains all the appbar persistent data, so that you can load and save them in the registry with the LoadSettings and SaveSettings methods. The RootKey and KeyName properties hold the location in the registry where settings must be stored. The SlideEffect, SlideTime, MinHorzDockSize, MinVertDockSize, MaxHorzDockSize and MaxVertDockSize properties were added. An incorrect behavior of the WM_NCHITTEST message handler, that was trapping Windows messages sent to non-windowed controls placed in the appbar client area, was fixed. The 'QuickBar.dpr' sample application and related files were added. NOTES OF THE AUTHOR * The TAppBar class is largely based on the J.Richter's CAppBar MFC Class. * TAppBar is completely FREEWARE. * Comments, suggestions and improvements are welcome.