Autor Beitrag
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 27.04.07 01:46 
huhu, ich hab im easy helper den code gefunden

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
const         
  FarbArray : array [0..15] of TColor = (clBlack,clMaroon, clGreen, clOlive,
                                      clNavy, clPurple, clTeal, clGray,
                                      clSilver, clRed, clLime, clYellow,
                                      clBlue, clFuchsia, clAqua, clWhite);

procedure TForm10.ColorBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
const
  cBrushColors: array [Boolean] of TColor = (clWindow, clHighlight);
  cPenColors: array [Boolean] of TColor = (clWindowText, clHighlightText);
begin
  Assert(Control is TCombobox);
  with (Control as TComboBox).Canvas do
  begin
   // Hintergrund und Text Farbe bestimmen, anschließend den Hintergrund löschen
   Brush.Color:= cBrushColors[(OdSelected in State) or (OdFocused in State)];
   //Font.Color := cPenColors[(OdSelected in State) or (OdFocused in State)];
   FillRect(Rect);

   Rect.Right:= 20;  //30
   Textout(Rect.Right + 5, Rect.Top + 1, (Control as TComboBox).Items[Index]);
   // Jetzt gleichen wir das Rect für die Farbbox an
   // und anschließend zeichen wir diese ...
   InflateRect(Rect, 0, -2);
   OffsetRect(Rect, 2, 0);
   Brush.Style := bsClear;
   Brush.Color := FarbArray[Index];
   Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
  end;
end;


so nun das problem ;D

ich hätt da gern eine standartfarbe vor dem aufruf von drawitem also z.b. beim form.show möchte ich das z.b. die schwarze farbe schon drin ist ohne diese erst auswählen zumüssn
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Fr 27.04.07 05:38 
(a) im OnCreate der Box die Farbe setzen
(b) oder ItemIndex := 0;
(c) TColorBox verwenden

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Ironwulf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 27.04.07 21:34 
thx ich machs über itemindex, die anderen sind nicht möglich da ne combobox kein oncreate hat und colorboxen scheint es (noch?) nicht zugeben in meinem delphi