2012-04-10 2 views
3

VCL 스타일 윈도우 요소를 그릴 때 잘못 구운 페인팅 문제가 있습니다. 모서리가 둥근 스타일에서는 컨트롤의 경계 사각형과 스타일의 둥근 윈도우 모서리 사이의 공간에 흰색 배경이 나타납니다.Delphi XE2 스타일로 페인팅

enter image description here

위의 이미지는 아쿠아 라이트 슬레이트를 사용하여 실행했지만, 모서리가 둥근 어떤 스타일이 같은 문제를 표시합니다. 내가 뭘 놓치고 있니?

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; 
+0

, 나는 또한 ParentBackground을 시도했다. csOpaque가 제거되었는지 확인해보십시오. –

+0

'StyleServices.DrawElement' 메소드를 디버깅하여 캔버스에 비트 맵을 그리는 방법을 보았습니까? – RRUZ

+0

솔직히 나는 테마 엔진의 내부로 뛰어 들지 않기를 바랬지 만, 아무도 더 좋은 아이디어가 없다면 그것은 내가해야 할 일이다. –

답변

4

네, 질문에 몇 분을 보내고 답변을 찾았습니다. 둥근 모서리를 그리는 열쇠는 StyleServices.GetElementRegion 함수를 호출하여 영역을 가져온 다음 SetWindowRgn 함수를 사용하여 영역을 컨트롤에 적용합니다. = 사실, 변화 없음 :

확인이 샘플

procedure TSample.Paint; 
var 
    Details : TThemedElementDetails; 
    Region : HRgn; 
    LRect : TRect; 
begin 
    Details := StyleServices.GetElementDetails(twCaptionActive); 
    LRect := Rect(0, 0, Width, Height); 
    StyleServices.GetElementRegion(Details, LRect, Region); 
    SetWindowRgn(Handle, Region, True); 
    StyleServices.DrawParentBackground(Self.Handle, Canvas.Handle, Details, False); 
    StyleServices.DrawElement(Canvas.Handle, Details, ClientRect); 
end; 

는 그리고이 BTW 결과

enter image description here

+0

이것은 절대적으로 도움이됩니다. 이것은 캡션 영역에 대해 오프 스크린 비트 맵을 사용하는 경우에도 작동합니다. 비슷한 일을하는 다른 모든 사람들에게는 GetElementRegion에 전체 클라이언트 rect를 전달해야한다는 점을 지적하는 것이 중요합니다. –