我在繪製VCL風格的窗口元素時遇到繪畫不正確的問題。在具有圓角的樣式上,我在控件邊界矩形和樣式的圓角窗口角之間的空白處獲得了白色背景。Delphi XE2風格繪畫
上面的影像是用水族光板岩運行,但帶有圓角的任何風格會顯示此相同的問題。我錯過了什麼?
type
TSample = class(TCustomControl)
protected
procedure Paint; override;
end;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
R: TRect;
S: TSample;
begin
R := ClientRect;
InflateRect(R, -20, -20);
S := TSample.Create(Application);
S.Parent := Self;
S.BoundsRect := R;
end;
{ TSample }
procedure TSample.Paint;
var
Details: TThemedElementDetails;
begin
Details := StyleServices.GetElementDetails(twCaptionActive);
StyleServices.DrawParentBackground(Self.Handle, Canvas.Handle, Details, False);
StyleServices.DrawElement(Canvas.Handle, Details, ClientRect);
end;
順便說一句,我也試過ParentBackground:=真,沒有任何變化。也嘗試確保csOpaque被刪除。 – 2012-04-10 18:36:01
您是否嘗試調試'StyleServices.DrawElement'方法以查看它如何在畫布中繪製位圖? – RRUZ 2012-04-10 21:47:34
坦率地說,我希望避免潛入主題引擎的內部,但如果沒有人有更好的想法,那就是我必須做的。 – 2012-04-11 17:32:27