O ile mi wiadomo, tylko obejście dla tego problemu jest ownerdraw combobox
Spróbuj kroki
- ustawić właściwość styl combobox do
csOwnerDrawFixed
- W przypadku OnDrawItem użyj metod styli vcl, aby narysować elementy combobox.
Sprawdź ten przykładowy kod
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;
Więcej informacji można sprawdzić ten artykuł Vcl Styles and Owner Draw
. Możesz także użyć jednostki Vcl.Styles.OwnerDrawFix (część vcl-styles-utils project), która obejmuje zestaw procedur rysowania właściciela dla komponentów takich jak TListBox, TComboBox i TListView.
+1, Reguły RRUZ. –
Tak, czekam na pierwsze pytanie, które zadaje pytanie o style VCL z WMI ..... –
@David, LOL ... –