5
Delphi XE2。有一個表格&。德爾福:問題與GDI +&梯度框架/矩形
窗體和框架是doublebuffered
。 GlassFrame
已啓用。
我畫框的背景,並嘗試繪製一個右對齊的矩形,但有錯誤。尤其是我在調整大小時出現了錯誤。
矩形不希望從透明度正常繪製到不透明的黑色。
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;
請幫我從透明度通常繪製漸變框架上的一個矩形不透明黑色。
謝謝!但這不是我想要的。請下載上面的項目並調整窗體大小,您將看到矩形的顏色發生變化。 – maxfax 2012-01-12 17:21:14
查看我的更新。打開/關閉玻璃框架仍然是一個奇怪的效果。框架邊緣從玻璃框架兩側的高度35左右開始。似乎是某個系統中的一個錯誤。 – 2012-01-12 18:13:14
如果您註銷PaintWindow過程並打開/關閉玻璃框,玻璃框架功能障礙更加明顯。 – 2012-01-12 18:27:30