TsComboBox.Style = csOwnerDrawFixed

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37481
    Schmidtze
    Participant

    Hello,

    I have a TsComboBox in which I want to show some items disabled, let's say grayed out. “Disabled” does not mean that it can't be selected! My question is, how to do this? I can't simply use colors like clWindowText and clGrayText as these colors do not match perhaps the current skin style. By now my code looks like this:

    Code:
    procedure TMyForm.comboBoxDrawItem(Control: TWinControl;
    Index: Integer; Rect: TRect; State: TOwnerDrawState);
    var
    comboBox: TsComboBox;
    begin
    comboBox := TsComboBox(Control);
    comboBox.Canvas.FillRect(Rect);
    if not (odSelected in State) then
    begin
    if not comboBox.DroppedDown
    and (Index = comboBox.ItemIndex)
    and GrayedOutCondition then
    comboBox.Canvas.Font.Color := clGrayText
    else
    comboBox.Canvas.Font.Color := clWindowText;
    end;
    comboBox.Canvas.TextOut(Rect.Left+2, Rect.Top, coItems.Items[Index]);
    end;

    where GrayedOutCondition is my condition for showing the item disabled.

    What do I have to do, which colors do I have to use, for the font and also for the background?

    Many thanks in advance

    Friedemann

    #56647
    Schmidtze
    Participant

    Hi,

    I think my question has been answered already here: Getting the main colors from SkinManager.

    Best regards

    Friedemann

    #56698
    Support
    Keymaster

    Hello

    Yes, the TsSkinManager Palette may be used for this purpose.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.