我正在使用启用了vcl样式的组合框,但是当我运行应用程序时,组合框使用的高亮颜色是窗口高亮颜色,而不是vcl样式。组合框不使用vcl样式高亮颜色。
我该如何解决这个问题,我的意思是在组合框中使用vcl样式高亮颜色?
我正在使用启用了vcl样式的组合框,但是当我运行应用程序时,组合框使用的高亮颜色是窗口高亮颜色,而不是vcl样式。组合框不使用vcl样式高亮颜色。
我该如何解决这个问题,我的意思是在组合框中使用vcl样式高亮颜色?
据我所知,唯一的解决方法对于这个问题,是的OwnerDraw组合框
请尝试以下步骤
csOwnerDrawFixed
入住此示例代码
uses
Vcl.Styles,
Vcl.Themes,
procedure TForm115.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
const
ColorStates: array[Boolean] of TStyleColor = (scComboBoxDisabled, scComboBox);
FontColorStates: array[Boolean] of TStyleFont = (sfComboBoxItemDisabled, sfComboBoxItemNormal);
var
LStyles : TCustomStyleServices;
begin
LStyles :=StyleServices;
with Control as TComboBox do
begin
Canvas.Brush.Color := LStyles.GetStyleColor(ColorStates[Control.Enabled]);
Canvas.Font.Color := LStyles.GetStyleFontColor(FontColorStates[Control.Enabled]);
if odSelected in State then
Canvas.Brush.Color := LStyles.GetSystemColor(clHighlight);
Canvas.FillRect(Rect) ;
Canvas.TextOut(Rect.Left+2, Rect.Top, Items[Index]);
end;
end;
欲了解更多信息,您可以检查本文Vcl Styles and Owner Draw
。您也可以使用Vcl.Styles.OwnerDrawFix单元(vcl-styles-utils project的一部分),其中包含一组所有者为TListBox,TComboBox和TListView等组件绘制例程。
这应该是一个RRUZ。 :)
见他的博客:http://theroadtodelphi.wordpress.com/2012/03/14/vcl-styles-and-owner-draw/
(保持代表为他即将到来的答案,但你会得到一个开始^ _ ^)
+1,RRUZ规则。 – 2012-03-16 18:17:07
是啊,我在等待第一个问题,询问如何用WMI查询VCL样式..... – 2012-03-16 18:39:34
@David,LOL ... – 2012-03-16 18:52:58