2011-01-26 4 views
1

내 응용 프로그램은 표준 TComboBox 및 TButtonedEdits를 사용하여 더 복잡한 드롭 다운 패널을 사용하여 컨트롤을 생성합니다. 두 컨트롤을 똑같이 보이게하고 싶습니다. 특히, 현재 TButtonedEdits에 대한 이미지를 프로그램이 실행될 현재 또는 미래의 운영 체제에 관계없이 TComboBoxes의 이미지와 동일하게 만듭니다 (즉, 이미지가 운영 체제에 의해 결정되고 Delphi가 아닌 것으로 가정).).TButtonedEdit 이미지를 TComboBox 기본 이미지에 일치

TBombedEdits에서 사용할 수 있도록하기 위해 TComboBox에 이미지를 제공하는 리소스를 런타임에 TImageList에 설치해야한다고 가정합니다. 해당 자원을 찾아 추출하는 방법은 무엇입니까?

답변

2

당신은 버튼을 직접 그릴 테마 엔진을 사용할 수 있습니다 - 우선이 같은 시도 :

(엠바 카데로 포럼에 스레드 "Windows themes in combobox"에서 적응)
uses 
    Themes; 

procedure DrawComboBoxButton(ACanvas: TCanvas; ADown, AMouseInControl: Boolean; const ARect: TRect); 
var 
    ComboElem: TThemedComboBox; 
    Details: TThemedElementDetails; 
begin 
    if ThemeServices.ThemesEnabled then 
    begin 
    if ADown then 
     ComboElem := tcDropDownButtonPressed 
    else if AMouseInControl then 
     ComboElem := tcDropDownButtonHot 
    else 
     ComboElem := tcDropDownButtonNormal; 
    Details := ThemeServices.GetElementDetails(ComboElem); 
    ThemeServices.DrawElement(ACanvas.Handle, Details, ARect); 
    end 
    else 
    begin 
    if ADown then 
     DrawFrameControl(ACanvas.Handle, ARect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX or DFCS_PUSHED) 
    else 
     DrawFrameControl(ACanvas.Handle, ARect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX); 
    end; 
end; 

procedure TForm1.PaintBox1Paint(Sender: TObject); 
begin 
    DrawComboBoxButton(PaintBox1.Canvas, False, False, Bounds(0, 0, 20, 20)); 
    DrawComboBoxButton(PaintBox1.Canvas, True, False, Bounds(20, 0, 20, 20)); 
end; 

.

Mike Lischke의 "Windows XP Theme Explorer"은 "요소"및 "세부 정보"를 올바르게 찾을 수 있도록 도와줍니다. 그리고 this SO thread을보십시오.

+0

나는 구글 tcDropDownButtonNormal을했고 몇몇 코드 예제를 발견했다. 불행하게도 나는 테마 엔진에 대한 지식이나 이해가 없으므로 Google에 시도하는 것은 이전의 제 3 자 엔진에 대한 참조 만 얻었습니다. 당신은 이것을 읽을만한 곳이 있습니까? –

관련 문제