![]() |
TComboBox unter Windows 10
Bekanntermaßen wird die ComboBox mit der Eigenschaft 'DropDownList' unter Windows 10 bei Enabled=True grau dargestellt. Ein Verhalten, das weder ich, noch meine Anwender hinnehmen wollen.
Auf 'Stackoverflow' bin ich auf folgende Lösung des Problems gestoßen. Leider zeigen sich meine ComboBoxen (Delphi 10.2) davon völlig unberührt. Falls also jemand einen Tipp hat, wie man den ComboBoxen einen frischeren Anstrich verpassen kann, wäre ich sehr dankbar.
Delphi-Quellcode:
type
TComboBoxStyleHookExt= class(TComboBoxStyleHook) procedure UpdateColors; strict protected procedure WndProc(var Message: TMessage); override; public constructor Create(AControl: TWinControl); override; end; TWinControlClass= class(TWinControl); implementation constructor TComboBoxStyleHookExt.Create(AControl: TWinControl); begin inherited; UpdateColors; end; procedure TComboBoxStyleHookExt.UpdateColors; const ColorStates: array[Boolean] of TStyleColor = (scComboBoxDisabled, scComboBox); FontColorStates: array[Boolean] of TStyleFont = (sfComboBoxItemDisabled, sfComboBoxItemNormal); var LStyle: TCustomStyleServices; begin if Control.Enabled then //use the control colors begin Brush.Color := TWinControlClass(Control).Color; FontColor := TWinControlClass(Control).Font.Color; end else begin //if not enabled. use the current style colors LStyle := StyleServices; Brush.Color := LStyle.GetStyleColor(ColorStates[Control.Enabled]); FontColor := LStyle.GetStyleFontColor(FontColorStates[Control.Enabled]); end; end; procedure TComboBoxStyleHookExt.WndProc(var Message: TMessage); begin case Message.Msg of WM_CTLCOLORMSGBOX..WM_CTLCOLORSTATIC, CN_CTLCOLORMSGBOX..CN_CTLCOLORSTATIC: begin UpdateColors; SetTextColor(Message.WParam, ColorToRGB(FontColor)); SetBkColor(Message.WParam, ColorToRGB(Brush.Color)); Message.Result := LRESULT(Brush.Handle); Handled := True; end; CM_ENABLEDCHANGED: begin UpdateColors; Handled := False; end else inherited WndProc(Message); end; end; initialization TStyleManager.Engine.RegisterStyleHook(TComboBox, TComboBoxStyleHookExt); end. |
AW: TComboBox unter Windows 10
Hast du in deinem Programm denn auch VCL-Styles aktiv? Andernfalls glaube ich kaum, dass der Style-Hook irgendeine Relevanz haben wird.
|
AW: TComboBox unter Windows 10
Zitat:
Nur kann ich mit den Styles überhaupt nichts anfangen. Wenn noch jemand eine Lösung ohne Styles hat... |
AW: TComboBox unter Windows 10
Mal doch mal ein Bild um zu zeigen was Du gerne als Ergebnis hättest.
|
AW: TComboBox unter Windows 10
Zitat:
|
AW: TComboBox unter Windows 10
Zitat:
|
AW: TComboBox unter Windows 10
Zitat:
Das sich dann mit deinem zusätzlichen Hook nichts tut sollte klar sein. Aber irgendwie verstehe ich dein Problem nicht. So wie Bernhard Geyer: sagt Ohne VCL-Styles und alles selber machen... oder nur die VCL-Styles ohne Hook verwenden. Die Comboboxen werden ja abhängig vom verwendeten Skin schon Überzeichnet du würdest also alles doppelt machen, was die Styles wenn sie richtig funktionieren nicht zulassen würden\sollten. |
AW: TComboBox unter Windows 10
Da der Hook später registriert wird als der VCL-eigene hat er auch Vorrang. Es funktioniert ja auch wie gewünscht, wenn man VCL-Styles einschaltet.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:50 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz