also ich habe (da ich es brauche) mir eine farbige Listbox und Combobox programmiert.
Die Listbox klappt super, doch bei der Combobox ist das ARect irgendwie falsch...
Siehe Bild im Anhang.
Doch es hat einige Zeit mal funktioniert. Ich habe keine Ahnung wieso...
Der wichtige Code ist dieser:
Code: Alles auswählen
procedure TColoredComboBox.DrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState);
begin
if Assigned(OnDrawItem) then
OnDrawItem(Self, Index, ARect, State)
else if (Index>=0) and (Index < Items.Count) then
begin
if (0<=Index) and (Index<=FItemColors.Count-1) then
if DroppedDown and (odSelected in State) then
Canvas.Font.Color:=clHighlightText
else
Canvas.Font.Color:=StringToColor(FItemColors.Strings[Index]);
if (0<=Index) and (Index<=FItemBackgroundColors.Count-1) then
if DroppedDown and (odSelected in State) then
Canvas.Brush.Color:=clHighlight
else
Canvas.Brush.Color:=StringToColor(FItemBackgroundColors.Strings[Index]);
Canvas.FillRect(aRect);
Canvas.Brush.Style := bsClear;
Canvas.TextRect(aRect, aRect.Left + 2, aRect.Top, Items[Index]);
end;
end;
Wisst ihr weiter? Wieso ist das aRect falsch? Es muss doch eigentlich richtig sein....
Gruß Alexander