您可以使用主题引擎给自己绘制按钮 - 尝试这样对于初学者:
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;
(在英巴卡迪诺论坛改编自线程"Windows themes in combobox")。
Mike Lischke的"Windows XP Theme Explorer"可以帮助您找到正确的“Elements”和“Details”。并看看this SO thread。
我没有谷歌tcDropDownButtonNormal,并找到一些代码示例。不幸的是,我没有对主题引擎的知识或理解,并试图谷歌_that_只让我参考旧的第三方引擎。你有什么建议可以在某个地方阅读吗? – 2011-01-28 03:50:07