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;