Class TPGCaptionBar (unit PGDsgFrm) |
Inherits from
TPGFormSubclass
constructor Create(AOwner:TComponent);
- TPGCaptionBar
procedure BeginUpdate;
function CaptionBarComponentAtPos(X,Y: Integer; var AMouseTarget: TPGCaptionBarComponent): Boolean;
Checks to see if a a caption bar component is at a screen position.
destructor Destroy;
function DoingUpdate: Boolean;
PGAssert( (UpdateCount >= 0), 'Start and EndUpdates dont match up.
procedure EndUpdate;
procedure Loaded;
If a popup menu is being removed from the form, and it is the popup menu } { of one of the caption bar components, then remove it from the caption bar } { component's properties.
procedure Notification(Component: TComponent; Operation: TOperation);
Restore the non client window styles that were interfering with our } { painting in the non client area, but are neccesary for a form to } { paint itself without our intervention.
procedure Refresh;
Copy the memory caption bar onto the real caption bar in one quick step.
procedure RefreshAfterRedrawing;
Ensure that all changes are displayed.
procedure AddCaptionBarComponent(AComponent: TPGCaptionBarComponent);
procedure AutosizeCaptionBar;
If a really large height is being set, then ask the developer } { if they are sure that they really want to set it.
function AutosizingButtons: Boolean;
function AutosizingCaptionBar: Boolean;
function BorderOffset(var x,y: Integer; const dx,dy:Integer; TargetHitTest:array of integer): Boolean;
Used to calculate the bounds of the caption bar rect.
function CalcHorzOffset: Integer;
Returns the logical position from the left of the } { window that the caption bar rect begins at.
function CalcVerticalOffset: Integer;
Returns the logical position from the top of the } { window that the caption bar rect begins at.
function CaptionBarComponents(AnIndex: Integer): TPGCaptionBarComponent;
Methods used to manage Caption Bar Components A wrapper function used for returning a specified component } { in the caption bar components list as a TPGCaptionBarComponent.
function DisplayDesignTimeDialog(const AnAction: Integer): Boolean;
procedure DoneWaitingForDoubleClick(Sender: TObject);
Timer event that evaluates which mouse event has occurred, a single } { click, or a double click.
procedure DrawCaptionBar(APaintOperation: TPGCaptionBarPaintOperation);
Procedures used in actually painting the form Paints the form
procedure DrawCaptionBarBackground;
Paints the form's caption bar.
procedure DrawCaptionBarComponent(const ACaptionBarComponent: TPGCaptionBarComponent);
If just this caption bar component is being destroyed, then } { tell the caption bar to redraw itself.
procedure EditComponentAtDesignTime(AComponent: TComponent);
procedure GetCaptionBarBoundsRect(var ARect: TRect);
procedure GetCaptionBarPaintRect(var ARect: TRect);
procedure GetCaptionBarWindowRect(var ARect: TRect);
function GetHeight: Integer;
function GetMaxSizeByClass(TargetClass: TComponentClass; var ASize: TPoint): Boolean;
Find out the minimum size that the component is allowed to get.
function GetMinAllowedSizeByClass(TargetClass: TComponentClass; var LargestSize: TPoint): Boolean;
function GetMinFormSize: TPoint;
Optimization
AWindowRect := CapBarVcl.
function GetNormalCapBarHeight: Integer;
Returns our own normal caption bar height, since GetSystemMetrics is } { somewhat inconsistent on this result.
function GetSystemButtons: TPGSystemButtonKinds;
Returns a set of the kinds of system buttons that are being } { displayed in the caption bar of the parent form.
function GetSystemMenuButton(var SysMenuButton: TPGCaptionBarSystemButton): Boolean;
function HitTestInfo(xPos: Integer; yPos: Integer): LongInt;
Used to define the paintable area of the caption bar
function InCaptionBarRect(var ARect: TRect; APoint: TPoint): Boolean;
Return whether or not the point is in the bottom of the non client area.
function InNonClientBottom(APoint: TPoint): Boolean;
function IsDesignTime: Boolean;
Design time interface.
function IsRuntime: Boolean;
function KeepingButtonsSameSize: Boolean;
Update the components height.
function LoadingFromStream: Boolean;
Notify the caption bar components that we are done loading } { the caption bar component.
procedure LockUpdates;
Refresh management handlers Used to keep track of whether or not the caption bar is allowed to } { paint itself.
function MakeSameSizeByClass(const CapBarVcl: TPGCaptionBarComponent; TargetClass: TComponentClass;
const UpdatingWidth: Boolean; const UpdatingHeight: Boolean): Boolean;
Iterates throught each of the caption bar components of class } { type 'TargetClass' and makes them the same size as the passed caption } { bar component "CapBarVcl", in the specified dimensions.
function MouseTarget: TPGCaptionBarComponent;
Process click or double click, whichever it was.
function MouseTargetAt(XPos: Integer; YPos: Integer): Boolean;
Returns true if the mouse down target is at (XPos, YPos) } { otherwise it returns false.
function MouseTargetIsValid: Boolean;
procedure OnPictureChanged(Sender: TObject);
Delphi 3.
procedure RefreshOffsets;
Figures out the paintable non client area offsets.
procedure RemoveCaptionBarComponent(AComponent: TPGCaptionBarComponent);
procedure ResetUpdateCount;
procedure RestoreSubclass(Sender: TObject);
function SelectComponentAtDesignTime(const AComponent: TComponent): Boolean;
procedure SetActiveColor(Value: TColor);
procedure SetHeight(Value: Integer);
procedure SetInactiveColor(Value: TColor);
function SetNonClientWindowStyles(const AHandle: THandle; const IsActive: Boolean): Boolean;
Painting the non client area of a form requires that we have } { complete control over *when* painting occurs in the non client area.
procedure SetOptions(Value: TPGCaptionBarOptions);
procedure SetPicture(Value: TBitmap);
procedure SetTransparent(Value: Boolean);
Property management
procedure SetTransparentColor(Value: TColor);
procedure SetVertMargin(Value: Integer);
procedure StartWaitingForDoubleClick;
Starts a timer used in checking if a double click has occurred.
function TestWinStyle(dwStyleBit : longint) : boolean;
procedure UnlockUpdates;
function VertOffset: Integer;
function Width: Integer;
procedure WMActivate(var Message: TWMActivate);
Intercepted so we can know if the form is the currently active } { window when we paint the caption bar.
procedure WMCancelMode(var Message: TWMCancelMode);
If some system process interrupts our mouse capturing, stop the mouse } { capture, and let the system process proceed.
procedure WMCommand(var Message : TMessage);
procedure WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
The component was double clicked, finish the double click sequence.
procedure WMKeyUp(var Message : TWMKeyUp);
procedure WMLButtonUp(var Message:TWMLButtonUp);
Tell the target caption bar component if we are over it.
procedure WMMouseMove(var Message: TWMMouseMove);
Note: The reason that WMMouseMove is being captured is because } { all mouse move message, even non-client messages, are converted } { to WMMouseMove messages when the mouse is being captured.
procedure WMNCCalcSize(var Message: TWMNCCalcSize);
Delphi 1.
procedure WMNCHitTest(var Message: TWMNCHitTest);
procedure WMNCLButtonDblClk(var Message:TWMNCLButtonDblClk);
Remove the mouse target.
procedure WMNCLButtonDown(var Message:TWMNCLButtonDown);
Message Handlers
procedure WMNCMouseMove(var Message: TWMNCMouseMove);
procedure WMSize(var Message: TWMSize);
procedure WMSysChar(var Message : TWMSysChar);
procedure WMSysCommand(var Message: TWMSysCommand);
Set the minimum positions and sizes
procedure WMSysKeyDown(var Message : TWMSysKeyDown);
procedure WMSysKeyUp(var Message : TWMSysKeyUp);
procedure WndProc(var Message: TMessage);
property ActiveColor : TColor
property Designer : Boolean
property Height : Integer
property InactiveColor : TColor
property Options : TPGCaptionBarOptions
property Picture : TBitmap
property Title : TPGCaptionBarGlyph
property Transparent : Boolean
property TransparentColor : TColor
property VertMargin : Integer
property Canvas : TCanvas
FActiveColor : TColor;
FCanvas : TCanvas;
FCaptionBarComponents : TList;
FDesigner : Boolean;
FHeight : Integer;
FInactiveColor : TColor;
FMouseTarget : TPGCaptionBarComponent;
FOptions : TPGCaptionBarOptions;
FPicture : TBitmap;
FTitle : TPGCaptionBarGlyph;
FTransparent : Boolean;
FTransparentColor : TColor;
FVertMargin : Integer;
GettingHitTestInfo : Boolean;
LeftOffset : Integer;
MemBmp : TBitmap;
MouseTargetStartingState : TPGGlyphState;
PaintRect : TRect;
RightOffset : Integer;
State : TPGCaptionBarState;
TopOffset : Integer;
TransparentPicture : TBitmap;
UpdateCount : Cardinal;
WaitForDoubleClick : TTimer;
WindowActive : Boolean;
constructor Create(AOwner:TComponent);
TPGCaptionBar
procedure BeginUpdate;
function CaptionBarComponentAtPos(X,Y: Integer; var AMouseTarget: TPGCaptionBarComponent): Boolean;
Checks to see if a a caption bar component is at a screen position. } { If a component was found: } { The function returns true, and sets 'AMouseTarget' to point } { to the component that was found. } { If a component was not found: } { The function returns false, and sets 'AMouseTarget' to nil.
destructor Destroy;
function DoingUpdate: Boolean;
PGAssert( (UpdateCount >= 0), 'Start and EndUpdates dont match up.');
procedure EndUpdate;
procedure Loaded;
If a popup menu is being removed from the form, and it is the popup menu } { of one of the caption bar components, then remove it from the caption bar } { component's properties.
procedure Notification(Component: TComponent; Operation: TOperation);
Restore the non client window styles that were interfering with our } { painting in the non client area, but are neccesary for a form to } { paint itself without our intervention.
procedure Refresh;
Copy the memory caption bar onto the real caption bar in one quick step.
procedure RefreshAfterRedrawing;
Ensure that all changes are displayed.
procedure AddCaptionBarComponent(AComponent: TPGCaptionBarComponent);
procedure AutosizeCaptionBar;
If a really large height is being set, then ask the developer } { if they are sure that they really want to set it.
function AutosizingButtons: Boolean;
function AutosizingCaptionBar: Boolean;
function BorderOffset(var x,y: Integer; const dx,dy:Integer; TargetHitTest:array of integer): Boolean;
Used to calculate the bounds of the caption bar rect.
function CalcHorzOffset: Integer;
Returns the logical position from the left of the } { window that the caption bar rect begins at.
function CalcVerticalOffset: Integer;
Returns the logical position from the top of the } { window that the caption bar rect begins at.
function CaptionBarComponents(AnIndex: Integer): TPGCaptionBarComponent;
Methods used to manage Caption Bar Components
A wrapper function used for returning a specified component } { in the caption bar components list as a TPGCaptionBarComponent.
function DisplayDesignTimeDialog(const AnAction: Integer): Boolean;
procedure DoneWaitingForDoubleClick(Sender: TObject);
Timer event that evaluates which mouse event has occurred, a single } { click, or a double click. Once it has been determined, the appropriate } { event is fired.
procedure DrawCaptionBar(APaintOperation: TPGCaptionBarPaintOperation);
Procedures used in actually painting the form
Paints the form
procedure DrawCaptionBarBackground;
Paints the form's caption bar.
procedure DrawCaptionBarComponent(const ACaptionBarComponent: TPGCaptionBarComponent);
If just this caption bar component is being destroyed, then } { tell the caption bar to redraw itself.
procedure EditComponentAtDesignTime(AComponent: TComponent);
procedure GetCaptionBarBoundsRect(var ARect: TRect);
procedure GetCaptionBarPaintRect(var ARect: TRect);
procedure GetCaptionBarWindowRect(var ARect: TRect);
function GetHeight: Integer;
function GetMaxSizeByClass(TargetClass: TComponentClass; var ASize: TPoint): Boolean;
Find out the minimum size that the component is allowed to get.
function GetMinAllowedSizeByClass(TargetClass: TComponentClass; var LargestSize: TPoint): Boolean;
function GetMinFormSize: TPoint;
Optimization
AWindowRect := CapBarVcl.WindowRect;
if PtInRect(AWindowRect, APoint) then
function GetNormalCapBarHeight: Integer;
Returns our own normal caption bar height, since GetSystemMetrics is } { somewhat inconsistent on this result.
function GetSystemButtons: TPGSystemButtonKinds;
Returns a set of the kinds of system buttons that are being } { displayed in the caption bar of the parent form.
function GetSystemMenuButton(var SysMenuButton: TPGCaptionBarSystemButton): Boolean;
function HitTestInfo(xPos: Integer; yPos: Integer): LongInt;
Used to define the paintable area of the caption bar
function InCaptionBarRect(var ARect: TRect; APoint: TPoint): Boolean;
Return whether or not the point is in the bottom of the non client area.
function InNonClientBottom(APoint: TPoint): Boolean;
function IsDesignTime: Boolean;
Design time interface.
function IsRuntime: Boolean;
function KeepingButtonsSameSize: Boolean;
Update the components height.
function LoadingFromStream: Boolean;
Notify the caption bar components that we are done loading } { the caption bar component.
procedure LockUpdates;
Refresh management handlers
Used to keep track of whether or not the caption bar is allowed to } { paint itself.
function MakeSameSizeByClass(const CapBarVcl: TPGCaptionBarComponent; TargetClass: TComponentClass;
const UpdatingWidth: Boolean; const UpdatingHeight: Boolean): Boolean;
Iterates throught each of the caption bar components of class } { type 'TargetClass' and makes them the same size as the passed caption } { bar component "CapBarVcl", in the specified dimensions.
function MouseTarget: TPGCaptionBarComponent;
Process click or double click, whichever it was.
function MouseTargetAt(XPos: Integer; YPos: Integer): Boolean;
Returns true if the mouse down target is at (XPos, YPos) } { otherwise it returns false.
function MouseTargetIsValid: Boolean;
procedure OnPictureChanged(Sender: TObject);
Delphi 3.0 Specific Routines } { Delphi 2.0 and C++ Builder Specific Routines } { Delphi 1.0 Specific Routines
procedure RefreshOffsets;
Figures out the paintable non client area offsets.
procedure RemoveCaptionBarComponent(AComponent: TPGCaptionBarComponent);
procedure ResetUpdateCount;
procedure RestoreSubclass(Sender: TObject);
function SelectComponentAtDesignTime(const AComponent: TComponent): Boolean;
procedure SetActiveColor(Value: TColor);
procedure SetHeight(Value: Integer);
procedure SetInactiveColor(Value: TColor);
function SetNonClientWindowStyles(const AHandle: THandle; const IsActive: Boolean): Boolean;
Painting the non client area of a form requires that we have } { complete control over *when* painting occurs in the non client area. } { When a form has the WS_DLGFRAME window style, it will get extra } { non client painting messages that we can't intercept. The } { following routine is used to strip the form of this window style when } { the Caption bar component is created.
procedure SetOptions(Value: TPGCaptionBarOptions);
procedure SetPicture(Value: TBitmap);
procedure SetTransparent(Value: Boolean);
Property management
procedure SetTransparentColor(Value: TColor);
procedure SetVertMargin(Value: Integer);
procedure StartWaitingForDoubleClick;
Starts a timer used in checking if a double click has occurred.
function TestWinStyle(dwStyleBit : longint) : boolean;
procedure UnlockUpdates;
function VertOffset: Integer;
function Width: Integer;
procedure WMActivate(var Message: TWMActivate);
Intercepted so we can know if the form is the currently active } { window when we paint the caption bar.
procedure WMCancelMode(var Message: TWMCancelMode);
If some system process interrupts our mouse capturing, stop the mouse } { capture, and let the system process proceed.
procedure WMCommand(var Message : TMessage);
procedure WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
The component was double clicked, finish the double click sequence.
procedure WMKeyUp(var Message : TWMKeyUp);
procedure WMLButtonUp(var Message:TWMLButtonUp);
Tell the target caption bar component if we are over it. Note that we } { only notify the target component of changes if were over it, to simplify } { the processing needed to be done by each component.
procedure WMMouseMove(var Message: TWMMouseMove);
Note: The reason that WMMouseMove is being captured is because } { all mouse move message, even non-client messages, are converted } { to WMMouseMove messages when the mouse is being captured... as } { it is when a caption bar component is in the process of being clicked. } { So, to summarize, if this event is being received, we know that someone } { has "MouseDowned" on a caption bar component, are moving the cursor } { around, and have yet to release the mouse button.
procedure WMNCCalcSize(var Message: TWMNCCalcSize);
Delphi 1.0 Delphi 2.0
TNCCalcSize_Params = record TNCCalcSizeParams = packed record
rgrc: array[0..2] of TRect; rgrc: array[0..3] of TRect;
lppos: PWindowPos; lppos: PWindowPos;
end; end;
procedure WMNCHitTest(var Message: TWMNCHitTest);
procedure WMNCLButtonDblClk(var Message:TWMNCLButtonDblClk);
Remove the mouse target.
procedure WMNCLButtonDown(var Message:TWMNCLButtonDown);
Message Handlers
procedure WMNCMouseMove(var Message: TWMNCMouseMove);
procedure WMSize(var Message: TWMSize);
procedure WMSysChar(var Message : TWMSysChar);
procedure WMSysCommand(var Message: TWMSysCommand);
Set the minimum positions and sizes
procedure WMSysKeyDown(var Message : TWMSysKeyDown);
procedure WMSysKeyUp(var Message : TWMSysKeyUp);
procedure WndProc(var Message: TMessage);
property ActiveColor : TColor
property Designer : Boolean
property Height : Integer
property InactiveColor : TColor
property Options : TPGCaptionBarOptions
property Picture : TBitmap
property Title : TPGCaptionBarGlyph
property Transparent : Boolean
property TransparentColor : TColor
property VertMargin : Integer
property Canvas : TCanvas
FActiveColor : TColor;
FCanvas : TCanvas;
FCaptionBarComponents : TList;
FDesigner : Boolean;
FHeight : Integer;
FInactiveColor : TColor;
FMouseTarget : TPGCaptionBarComponent;
FOptions : TPGCaptionBarOptions;
FPicture : TBitmap;
FTitle : TPGCaptionBarGlyph;
FTransparent : Boolean;
FTransparentColor : TColor;
FVertMargin : Integer;
GettingHitTestInfo : Boolean;
LeftOffset : Integer;
MemBmp : TBitmap;
MouseTargetStartingState : TPGGlyphState;
PaintRect : TRect;
RightOffset : Integer;
State : TPGCaptionBarState;
TopOffset : Integer;
TransparentPicture : TBitmap;
UpdateCount : Cardinal;
WaitForDoubleClick : TTimer;
WindowActive : Boolean;