Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Die Delphi-IDE (https://www.delphipraxis.net/62-die-delphi-ide/)
-   -   Combobox-Hilfe (https://www.delphipraxis.net/80614-combobox-hilfe.html)

AeNima 12. Nov 2006 12:48


Combobox-Hilfe
 
Also ich möchte ein Programm schreiben im Stil von Windows paint .
Ich hab eine farbpallette in einer combobox .
Nun möchte ich ,dass wenn ich die farbe auswähle, ich auch mit der Farbe male.
Delphi-Quellcode:
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin

 with Control as TComboBox,Canvas do begin
    Brush.Color := clWhite;
    FillRect(Rect);
    InflateRect(Rect,-2,-2);
    Brush.Color := StrToInt(Items[Index]);
    FillRect(Rect);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
with ComboBox1.Items do begin
  Add(IntToStr(clRed));
  Add(IntToStr(clFuchsia));
  Add(IntToStr(clBlue));
  Add(IntToStr(clGreen));
  Add(IntToStr(clYellow));
end;
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
image1.canvas.pen.color:=clblue;
if a=1 then image1.canvas.lineto (x,y) ;
             image1.canvas.moveto (x,y);
label1.caption:=inttostr(x);
label2.caption:=inttostr(y);
end;
jede hilfe ist willkommen,denn ich komme mit meinem problem einfach nicht weiter

mkinzler 12. Nov 2006 12:55

Re: Combobox-Hilfe
 
Du nimmst auch immer clBlue. Warum nimmst du keine fertig Farbwahl-Komponente?

raiguen 13. Nov 2006 08:43

Re: Combobox-Hilfe
 
Moin :-)
Du solltest natürlich auch die STiftfarbe entsprechend der ausgewählten Farbe setzen ;)
Delphi-Quellcode:
image1.canvas.pen.color := StrToIntDef(Combobox1.Items[ComboBox1.ItemIndex],0);
//oder
image1.canvas.pen.color := StringToColor(Combobox1.Items[ComboBox1.ItemIndex]);

AeNima 15. Nov 2006 08:33

Re: Combobox-Hilfe
 
Hi ,


THX:D den befehl habe ich gebraucht danke .

Gruß

AeNima


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:38 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