Unit PGTray95

================================================================================ TPGTrayIcon95 - Super TrayIcon VCL ================================================================================ Note: See the help file PGTRAY95.HLP for information concerning published properties and methods. Classes: ============================================================================== Name Purpose TPGTrayIcon95 Windows 95 TrayIcon Component. TPGTrayIconAnimation Used to implement the Animation property of the TPGTrayIcon95 component. TPGTrayIconMsgWindow Used to intercept messages sent to the TrayIcon by Windows, and more generally moves the majority of the mouse handling routines out of the Super TrayIcon VCL. TPGTimerManager Manages a group of timed events using a single Windows Timer. Used to conserve windows timer resources for 16 bit applications. Associated Files: ============================================================================== PGBASE.INC An include unit that supplies some general conditional defines to make it easier to figure out which code is associated with the different versions of Delphi and C++ Builder respectively. CALL32NT.INC An include unit that provides access to the Win32 API for Delphi 1.0 applications. Note that this also involves some code in the initialization section. Used by the Delphi 1.0 version of the component. Many thanks to Christian Ghisler, CIS: 100332,1175 for releasing CALL32NT.PAS into the public domain, and for helping me figure out how to convert a 16 bit HIcon to a 32 bit HIcon. PGAPPWND.PAS Used to implement a hidden application window class. Used by the Delphi 1.0 Solution to solve a Windows NT 4.X LoadIcon problem, and by the Delphi 2.0 solution to initially hide the application on initial startup. PGHIDE32.PAS Used exclusively by the Delphi 2.0 solution in conjunction with the PGAPPWND.PAS file to initially hide the application on initial startup. PGTRAY16.DCR Component Resource for Delphi 1.0 PGTRAY32.DCR Component Resource for Delphi 2.0 History: ============================================================================== Ver Date(d/m/y) Programmer Comments 1.0 06/03/96 No One Creation. 2.0 20/05/96 No One Added the State and Animation properties, as well as the ability to use the component in Delphi 1.0 and Delphi 2.0. 2.1 18/06/96 No One Exposed a method to display the popup menu at the cursor position, "ShowPopupAtCursor". 2.2 26/08/96 No One Fixed a bug in the Delphi 2 version of the component that stopped the reception of tray messages. Also introduced the "MouseOver" event, the "ShowApplication" and "HideApplication" methods, and made the popup menu "non sticky" 3.0 08/02/97 No One Modified the "TPGTrayIconMsgWindow" class. It is now derived from TComponent instead of TWinControl to ensure that the callback window handle that Windows sends our TrayIcon messages to remains constant. It would change when the Form that the TrayIcon is on was Destroyed and Recreated, as modifying properties like TForm.FormStyle do when they are changed. - Introduced the Options property, the OnMouseEnter, OnMouseExit, OnAppMinimize, and OnAppRestore events. - Fixed 16 bit Win NT 4.0 bug that stopped the TrayIcon from being seen in the Tray. - Introduced more thorough solutions to hide the application on startup for Delphi 1.0 and 2.0. In conjunction with this, revised the ShowApplication and HideApplication methods to work when more than one form is visible on the screen. 3.1 16/07/97 No One - Exposed the PostEvent method, and made the ShowApplication, HideApplication and Click events use it to execute their code asynchronously. This was done to avoid bugs that occur with the delay between operation requests and application responses. - Fixed a bug that would cause Delphi itself to hide it's taskbar icon when minimized at design time. 3.2 23/07/97 No One - Added the ShowForm and ShowModalForm methods to allow Delphi 3.0 users to Show and Hide forms without the Applications' TaskBar icon being redisplayed. This problem was introduced in Delphi 3.0 by a change that Borland made to the Forms.pas file (see the TApplication.UpdateVisible routine). 3.3 23/07/97 No One - Updated the ShowForm, ShowModalForm, ShowApplication, HideApplication to allow forms and applications to be shown and hidden without displaying the Applications's TaskBar icon ever. This also involved some additions to the Options property, toCloseFormsOnHideApp, and toHideTaskBarIconOnShowApp. - As suggested by Richard K Peterson of Common Sense Solutions{css}, turned the Icon Index property into a Read AND write property, so the default animation sequence can be overriden. ================================================================================ Copyright © 1996,1997 No Name Software. All Rights Reserved ================================================================================

Classes

TPGNotifyOnFormClose - Used to hook into a forms OnClose event so we can be notified just } { before a Form closes.
TPGTimerItem -
TPGTimerManager - TPGTimerManager - Uses a single windows timer to manage a group of timed } { events.
TPGTrayIcon95 - TPGTrayIcon95 - Windows 95/NT TrayIcon Component } { Note: "LoadCurrentIcon" and "NotifyShell" are the key methods here.
TPGTrayIconAnimation -
TPGTrayIconMsgWindow -

Functions

PGShiftState - Returns the State keys that are currently depressed on the keyboard.
Register - Delphi 1.
RunTrayApplication - Replaces the Application.

Types

PGNOTIFYICONDATA
PPGNOTIFYICONDATA
TPGTimerInterval
TPGTrayIconAnimationOptions
TPGTrayIconOption
TPGTrayIconOptions
TPGTrayIconState
TPGTrayIconStateChangingEvent

Constants

Animation_Interval
NID_MAXTIP
PGNIF_ICON
PGNIF_MESSAGE
PGNIF_TIP
PGNIM_ADD
PGNIM_DELETE
PGNIM_MODIFY
TRAY_ICON_ID
WM_PGPOSTEVENT
WM_TRAY_CALLBACK

Variables

PGTrayIconDoubleClickTime


Functions


function PGShiftState: TShiftState;

Returns the State keys that are currently depressed on the keyboard. Used } { with the mouse events.

Used to determine the state of the Alt, Ctrl, and Shift keys, and } { the mouse buttons. Used by some of the mouse events.


procedure Register;

Delphi 1.0 specific code - Provides Delphi 1.0 access to the Win32 API. } { Include a modified version of CALL32NT.PAS in this component. This } { allows us to include the functionality of this unit without having to } { send the CALL32NT.DCU file along with the component. } { Include the components palette bitmap as a resource. This allows } { us to easily side step the incompatability of 16 and 32 bit resources. } {$IFDEF WIN32} {$R PGTRAY32.DCR} { Include the registration dialog if this is the shareware version.

procedure RunTrayApplication;

Replaces the Application.Run line for Delphi 1.0 and 2.0.

Required for the Delphi 1.0 Solution.


Types


PGNOTIFYICONDATA = record
cbSize : LongInt;
Wnd : LongInt;
uID : LongInt;
uFlags : LongInt;
uCallbackMessage : LongInt;
hIcon : LongInt;
szTip : array[0..63] of char;
end;

PPGNOTIFYICONDATA = ^PGNOTIFYICONDATA
Port of the 32 bit TrayNotification data structure to Delphi 1.0. } { Note: This ported structure is used for both the Delphi 1.0 and 2.0 } { versions of the component. The Delphi 2.0 version converts all } { values stored in this structure into the ShellApi unit version of } { the structure just before it uses the structure in the "NotifyShell" } { method of the TPGTrayIcon95 component.
TPGTimerInterval = 55..100000
TPGTrayIconMsgWindow - Message Window component } { Receives messages sent to the TPGTrayIcon95 by Windows, and more } { generally moves the majority of the mouse handling routines out } { of the TPGTrayIcon95 component.
TPGTrayIconAnimationOptions = (aoIconsInExe, aoIconsAreFiles);

TPGTrayIconOption = (toMinimizeToTray, toUnclutterDelphi1TaskBar, toCloseFormsOnHideApp, toHideTaskBarIconOnShowApp);

TPGTrayIconOptions = set of TPGTrayIconOption

TPGTrayIconState = (tsEnabled, tsDisabled, tsAnimated);

TPGTrayIconStateChangingEvent = procedure (Sender: TObject; var NewState: TPGTrayIconState) of object

Constants

Animation_Interval = 1000

The maximum length of the icon's hint.

NID_MAXTIP = 63

valid information. These flags can be } { used in combination with each other. } { Miscellaneous Constants

PGNIF_ICON = $00000002

Flags that indicate which fields in the

PGNIF_MESSAGE = $00000001

Used to remove the icon from the tray.

PGNIF_TIP = $00000004

PGNOTIFYICONDATA data structure contain

PGNIM_ADD = $00000000

Port of the TrayIcon messages to 16 bit windows. These values } { are identical to the values provided by the ShellApi unit that } { comes with Delphi 2.0, and are used when sending messages in both the } { Delphi 1.0 and 2.0 versions of the component.

PGNIM_DELETE = $00000002

Used to modify the icon in the tray.

PGNIM_MODIFY = $00000001

Used to add the icon to the tray.

TRAY_ICON_ID = 42

WM_PGPOSTEVENT = WM_USER + 101

WM_TRAY_CALLBACK = WM_USER + 100

Callback message and id used by Windows to send messages to the TrayIcon.

Variables

PGTrayIconDoubleClickTime : TPGTimerInterval

The time to wait between a single click and a double click when } { processing mouse events.