Class TGradientForm (unit GradForm) |
TForm
: TGradientForm is a descendant of the TForm class that paints it's caption bar in a gradient fill pattern, like the Microsoft Office applications. By default, it starts with black and moves gradually to the system defined caption color, although you can override these values. Also provided is an event to allow you to add your own custom painting on the caption bar.
Constructors |
Functions |
The caption rect is the rectangle we are interested in painting.
Clean up the font we created.
Make the non client area repaint.
NEVER leave this hanging.
hmmm, how to get it to show again in the IDE?
Windows sends this message when the window has been activated or deactivated.
Properties |
Events |
Variables |
Constructors |
Overridden methods { Create creates and initializes an instance of TGradientForm.
: Create creates and initializes an instance of TGradientForm. Call Create
to instantiate a TGradientForm at runtime. After calling the inherited
constructor, Create initializes the following properties:
Functions |
Destroy destroys an instance of TGradientForm.
: Destroy destroys an instance of TGradientForm. Do not call Destroy
directly in an application. Instead, call Free. Free verifies that the
instance is not already freed, and only then calls Destroy. This procedure is used to paint the caption gradient. : This procedure is used to paint the caption gradient. It is normally
called internally, but it can be used any time a repaint of the caption
is needed. The Active parameter is used to indicate whether the
caption should be painted as the active window or an inactive window. empty write method, just needed to get it to show up in Object Inspector Create a font for the caption bar. Create a font for the caption bar. Help only shows up in bsDialog style, and bsSizeable, bsSingle when there is no min or max button. Paint the given rectangle with the gradient pattern. Paint the given rectangle with the system solid color. Virtual methods useful for descandants The caption rect is the rectangle we are interested in painting. This will be the area that contains the caption icon, text and buttons. Are we running under Win98, and should we let it do it for us? Overriden methods Clean up the font we created. Paint the min/max/help/close buttons. Start filling bands Paint the icon for the system menu. Make the non client area repaint. Property methods Make the non client area repaint. Make the non client area repaint. Make the non client area repaint. Make the non client area repaint. Make the non client area repaint. Make the non client area repaint. Make the non client area repaint. Need to cause main form's caption to be redrawn, not the MDI child. Property storage qualifing methods Utility methods Use the percentage of each color to create each band color. MDI Client Window Procedure NEVER leave this hanging. Internal methods hmmm, how to get it to show again in the IDE? Don't do it if it was called from .SetCaption Window message handlers Windows sends this message when the window has been activated or deactivated. (Msg = WM_MDIREFRESHMENU) or Windows sends this message whenever any part of the non-client area (caption, window border) needs repainting. Windows would like to have a cursor displayed. I know, you're wondering why the hell I care about this, aren't you? Well, in the inherited handling (default Windows processing) of this message, if the mouse is over a resizeable border section, Windows repaints the caption buttons. Why? I have absolutely no idea. However, that's not the important part. When it repaints those buttons, it also repaints the background around them in the last color it painted the caption in. Now, usually this would just result in losing a few bands of the caption gradient, which 99.44% of all users would never notice. However, because we don't always allow default processing of WM_NCACTIVATE, sometimes Windows doesn't have the right idea about which color is currently the background. This cause the background to get painted in the wrong color sometimes, which 99.44% of all users *will* notice. We fix it by setting the appropriate cursor and not allowing the default processing to occur. Wasn't anything we cared about, so tell Windows we didn't handle it. The window has been resized. Windows sends this message if the user changes any of the system colors. Properties : Caption specifies a text string that appears in the caption bar. : CaptionTextColor is the color that should be used for the text draw in
the caption bar. You may have to adjust this color if you change the
: Determines the number of colors used to paint the gradient pattern. The
individual colors are determined by fading the start color into the stop
color. The number of times this is done is controled by this property.
The higher the number of colors, the smoother the gradient will appear.
However, the more colors that are used, the more complex the painting
will be.
: The leftmost gradient color. This is the color that is used at the
beginning of the caption (the far left), and is gradually faded into the
: The rightmost gradient color. This is the color that is used at the
end of the caption (the far right), and is gradually faded from the
: Determines if and when the gradient caption should be painted.
Properties Events : This event is fired after the icon, buttons and gradient are painted,
but just before the text is painted. It is not fired if the caption is
painted but not as a gradient, that is if
Variables Internal variables Property variables
Destroy is used to free resources allocated in the
procedure Draw(Active: boolean);
procedure Activate;
procedure CalculateColors;
procedure CreateWnd;
procedure Deactivate;
procedure DestroyWnd;
procedure DoShow;
function DrawCaption(FormDC: HDC; Active: boolean): TRect;
procedure FillRectGradient(DC: HDC; const R: TRect; Active: boolean);
procedure FillRectSolid(DC: HDC; const R: TRect; Active: boolean);
function GetCaptionRect: TRect;
function GetVersion: TDFSVersion;
procedure Loaded;
procedure PaintCaptionButtons(DC: HDC; var Rect: TRect);
procedure PaintCaptionText(DC: HDC; R: TRect; Active: boolean);
procedure PaintMenuIcon(DC: HDC; var R: TRect; Active: boolean);
procedure SetCaptionText(const Val: string);
procedure SetCaptionTextColor(Color: TColor);
procedure SetGradientColors(Val: integer);
procedure SetGradientInactiveStartColor(Color : TColor);
procedure SetGradientInactiveStopColor(Color : TColor);
procedure SetGradientStartColor(Color : TColor);
procedure SetGradientStopColor(Color : TColor);
procedure SetInactiveCaptionTextColor(Color: TColor);
procedure SetPaintGradient(Val: TGFPaintWhen);
procedure SetUseWin98Gradient(Val: boolean);
procedure SetVersion(const Val: TDFSVersion);
function StoreGradientInactiveStopColor: boolean;
function StoreGradientStopColor: boolean;
function Win98Check: boolean;
procedure CreateCaptionFont;
procedure GradClientWndProc(var Message: TMessage);
function IsActiveWindow: boolean;
procedure WMEnterIdle(var Msg: TWMEnterIdle);
procedure WMGetText(var Msg: TWMGetText);
procedure WMGetTextLength(var Msg: TWMGetTextLength);
procedure WMNCActivate(var Msg: TWMNCActivate);
procedure WMNCLButtonDown(var Msg: TWMNCLButtonDown);
procedure WMNCPaint(var Msg: TMessage);
procedure WMSetCursor(var Msg: TWMSetCursor);
procedure WMSetText(var Msg: TWMSetText);
procedure WMSettingChange(var Msg: TMessage);
procedure WMSize(var Msg: TWMSize);
procedure WMSysColorChange(var Msg: TWMSysColorChange);
procedure WMSysCommand (var Msg: TWMSysCommand);
property Caption : string
property CaptionTextColor : TColor
property GradientColors : integer
property GradientInactiveStartColor : TColor
property GradientInactiveStopColor : TColor
property GradientStartColor : TColor
property GradientStopColor : TColor
property InactiveCaptionTextColor : TColor
property PaintGradient : TGFPaintWhen
property UseWin98Gradient : boolean
property Version : TDFSVersion
event OnCaptionPaint : TGFOnCaptionPaint
Sender is the
TGradientForm that is being painted.
Canvas is the drawing
surface that is being painted. Anything you want to appear on the
caption must be drawn on this canvas. This canvas is not the actual
caption canvas, it is a memory bitmap (non-visible). This prevents
flicker as many things are being drawn since the actual visible drawing
only happens when the entire drawing operation is complete.
R is a rectangle that describes the area in which you can draw.
When the event is first fired, this rectangle will be the entire caption
less the system icon on the left (if any) and the caption buttons on the
right (if any). After performing your drawing operations, this value
should be modified so that the area you have painted is subtracted out.
This prevents the gradient from painting over what you have just done.
CaptionFont : HFONT;
Colors : array[0..1, 0..MAX_GRADIENT_COLORS-1] of TColorRef;
FCaptionText : string;
FCaptionTextColor : TColor;
FChangingActivationState : boolean;
FGradClientInstance : TFarProc;
FGradDefClientProc : TFarProc;
FGradientColors : integer;
FGradientInactiveStartColor : TColor;
FGradientInactiveStopColor : TColor;
FGradientStartColor : TColor;
FGradientStopColor : TColor;
FInactiveCaptionTextColor : TColor;
FOnCaptionPaint : TGFOnCaptionPaint;
FPaintGradient : TGFPaintWhen;
FRunningOnWin98 : boolean;
FUseWin98Gradient : boolean;
FUsingDefaultGradientInactiveStopColor : boolean;
FUsingDefaultGradientStopColor : boolean;