Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   ComboBox: Optik von csOwnerDrawFixed ähnlich wie csDropDownList (https://www.delphipraxis.net/158093-combobox-optik-von-csownerdrawfixed-aehnlich-wie-csdropdownlist.html)

Schorschi5566 5. Feb 2011 10:28


ComboBox: Optik von csOwnerDrawFixed ähnlich wie csDropDownList
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo DP,

der Titel sagt es eigentlich, was ich möchte. :)

Mit eingeschalteten Laufzeit-Themes sehen ComboBoxen mit csDropDownList recht nett aus (Hintergrund mit Verlauf).

Zwischen diesen Boxen habe ich aber eine, bei der csOwnerDrawFixed als Style benötigt wird.

Gibt es 'ne Möglichkeit, den Hintergrund der Combobox genauso "malen" zu lassen als wäre sie eine csDropDownList?

Danke im Voraus. ;)


Grüße,
Uwe

Schorschi5566 5. Feb 2011 16:41

AW: ComboBox: Optik von csOwnerDrawFixed ähnlich wie csDropDownList
 
Liste der Anhänge anzeigen (Anzahl: 1)
Jetzt isses schon etwas besser aber ich bekomme das entsprechende TRect nicht völlig über die Komponente. :(

Hier ist mal ein bissel Code. Vielleicht fällt ja jemandem ein, wie man das hinkriegen könnte...

Delphi-Quellcode:
procedure TCheckComboBox.DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  sOut : String;
  Details: TThemedElementDetails;
  ARect : TRect;
begin
  SetLength(Selected, TComboBox(Control).Items.Count);
  with TComboBox(Self).Canvas do
  begin
    FillRect(rect);

    ARect.Left := Rect.Left + 1;
    ARect.Right := Rect.Left + 13;
    ARect.Bottom := Rect.Bottom;
    ARect.Top := Rect.Top;

    if not (odComboBoxEdit in State) then
    begin
      if not (odSelected in State) and (Selected[Index]) then
        DrawFrameControl(Handle, ARect, DFC_BUTTON,
          DFCS_BUTTONCHECK or DFCS_CHECKED or DFCS_FLAT)
      else if (odFocused in State) and (Selected[Index]) then
        DrawFrameControl(Handle, ARect, DFC_BUTTON,
          DFCS_BUTTONCHECK or DFCS_CHECKED or DFCS_FLAT)
      else if (Selected[Index]) then
        DrawFrameControl(Handle, ARect, DFC_BUTTON,
          DFCS_BUTTONCHECK or DFCS_CHECKED or DFCS_FLAT)
      else if not (Selected[Index]) then
        DrawFrameControl(Handle, ARect, DFC_BUTTON, DFCS_BUTTONCHECK or DFCS_FLAT);

      TextOut(ARect.Left + 15, ARect.Top, TComboBox(Control).Items[Index]);
    end

// um den folgenden Part geht es...


    else // Text bei geschlossener ComboBox ohne Checkmarks
    begin
      sOut := '';
      for i := 0 to Items.Count - 1 do
      begin
        if Selected[i] then
          sOut := sOut + ItemsShort[i] + Separator;
      end;
      sOut := StrTrimRight(sOut, Char(Separator));
      ARect := Self.ClientRect;
      ARect.Top := ARect.Top - 1;
      ARect.Bottom := ARect.Bottom + 1;
      ARect.Left := ARect.Left - 1;
      ARect.Right := ARect.Right;
      Details := ThemeServices.GetElementDetails(tbPushButtonNormal);
      ARect := ThemeServices.ContentRect(Handle, Details, ARect);
      ThemeServices.DrawEdge(Handle, Details, ARect, EDGE_RAISED, BF_RECT);
      ThemeServices.DrawElement(Handle, Details, ARect);
      ARect.Left := ARect.Left + 4;
      ARect.Top := ARect.Top + 2;
      ThemeServices.DrawText(Handle, Details, sOut, ARect, BF_FLAT, BF_FLAT);
    end;
  end;
end;
Habe schon Bevels und dergleichen deaktiviert aber ich komme nicht in die linke obere Ecke...(siehe Screenshot)


Grüße,
Uwe

Keks 21. Feb 2014 15:27

AW: ComboBox: Optik von csOwnerDrawFixed ähnlich wie csDropDownList
 
Ich habe die gleiche Frage. Hast Du damals eine Lösung gefunden?
Oder weiß sonst noch jemand Rat?
Letztlich will ich nur die ausgeklappten Zeilen etwas umgestalten, nicht aber das Aussehen der auf der Form platzierten Komponente verändern.

Keks 25. Feb 2014 12:24

AW: ComboBox: Optik von csOwnerDrawFixed ähnlich wie csDropDownList
 
Kann wirklich keiner helfen? :(


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:06 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz