Delphi XE2. There is a form & a frame.
The form and the frame are doublebuffered. GlassFrame is enabled.
I paint frame’s background and try to draw a right aligned rectangle but have bugs. Especially I have bugs while resizing.
The rectangle doesn’t want to be drawn normally from transparency to the opaque black color.

uses ...GDIPAPI, GDIPOBJ...
type
TFrame2 = class(TFrame)
procedure PaintWindow(DC: HDC); override;
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
procedure TFrame2.PaintWindow(DC: HDC);
var
R: TGPRect;
pen: TGPPen;
Graphics: TGPGraphics;
linGrBrush: TGPLinearGradientBrush;
begin
R.X := 0;
R.Y := 0;
R.Width := self.Width;
R.Height := self.Height;
Graphics := TGPGraphics.Create(DC);
linGrBrush := TGPLinearGradientBrush.Create(R, MakeColor(255, 120, 248, 253),
MakeColor(255, 200, 216, 250), LinearGradientModeVertical);
Graphics.FillRectangle(linGrBrush, 0, 0, R.Width, R.Height);
linGrBrush.Free;
linGrBrush := TGPLinearGradientBrush.Create(MakePoint(0, 0),
MakePoint(189, 2), MakeColor(0, 0, 0, 0), MakeColor(255, 0, 0, 0));
Graphics.FillRectangle(linGrBrush, R.Width - 189, 79, 189, 2);
linGrBrush.Free;
Graphics.Free;
end;
Please help me to draw a rectangle on the gradient frame normally from transparency to the opaque black color.
Changing the code like shown below will draw a right aligned thin line from transparency to black opaque.
Update, using
InvalidateRectfor the whole area forces a total redraw of the frame.Otherwise the redraw might be clipped in strange ways.
This will solve your color change effect.
But a
GlassFramedefect is illustrated with the last two images below. The outside frame of the TFrame is not correctly visible on the top and upper sides.Showing dysfunction of TFrame when
GlassFrameis enabled (left).The right picture shows a complete black frame (even though in this picture the right side was cropped in compression) with
GlassFramedisabled.Update 2 :
Enable
SheetOfGlassand everything seems ok.Update 3 :
The
GlassFrametop property was set to 40, and caused the strange border effect around the frame. Setting it to 0 fixed this issue.