Autor Beitrag
Green
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 12:48 
also ich hab eine PaintBox und will das man mit der maus innerhalb dieser paintbox eine art rahmen wie auf dem desktop ziehen kann, und wenn man loslässt soll der ramen verschwinden und ich muss irgendwie an die koordinaten kommen... geht das?

mfG Green
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 20.05.06 12:58 
Klar geht das. mit Canvas.DrawRect kannst du ein Rechteck zeichnen, verschwinden lässt du es, in dem du nochmal eines der gleichen Größe zeichnest (nur in der hintergrundfarbe. ändere das mit Canvas.pen.Color)
In MouseDown setzt du eine boolean variable auf true und speicherst die koordinaten in einer TPoint Variable. in MouseMove zeichnest du dein Rechteck und überzeichnest immer sofort das alte, falls die boolean variable true ist. (nimm 4 TPoint Variablen, 2 für das neue Rechteck und 2 für das alte) in MouseUp setzt du die Variable auf false und überzeichnest ein letztes mal dein Rechteck in der Hintergrundfarbe. Die beiden Koordinaten sind in den TPoint Variablen. (denen für das "neue" Rechteck)
Vergiss DoubleBuffered:=true im FormCreate nicht...

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 13:00 
naja das problem is das die paintbox mit einem bild gefüllt ist d.h. ich nicht immer mit hintergrundfarbe übermalen kann...
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 20.05.06 13:08 
Dann überzeichne eben mit Canvas.Draw. Hierbei gibst du einfach als letzten Parameter die Grafik an, die bereits drin liegt.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 13:48 
hmm wie kann ich denn ein BIld in eine PaintBox einladen??

bei TImage geht das ja ganz leicht aber bei Paintbox find ich das nit

€: Wie kann ich denn das bild aus der paintbox speichern?
mit draw laden... das is klar, aber speichern?


Zuletzt bearbeitet von Green am Sa 20.05.06 13:51, insgesamt 2-mal bearbeitet
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 20.05.06 13:50 
Dann arbeite doch mit einem Image? Der unterschied zur PaintBox .. Naja ich kenn ihn nich, aber ich glaub nich, dass der sich so groß auswirkt...

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 13:52 
der unterschied is groooooß: wenn ich die funktion auf image anwende dann geht das n bissel und dann kommt auf einen schlag das bild. bei PaintBox geht das von links nach rechts 'durch' also man wartet nicht ewig und dann machts zack sondern es baut sich auf
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 20.05.06 13:54 
... ... hä? x( Naja dann mach doch sobald das Bild eben fertig ist, image.Canvas.Assign(PaintBox.Canvas); und überzeichne das Rechteck auf der PaintBox mit Canvas.Draw(0,0,Image1.Picture.Grafic);

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 13:57 
also: ich habe eine funktion in der ein Bild dynamisch ERSTELLT wird. das geht aber eineige sekunden.
--> ich habe keine datei in der dieses Bild vorhanden ist und um es immer wieder neu zu zeichnen geht das zu lang
also nach jedem zeichnen temporär zwischenspeichern aber wie?
wie kann ich das bild das in einer PaintBox ist speichern?

mfG Green
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 20.05.06 13:58 
Wie schon gesagt: Image1.Canvas.Assign(PaintBox1.Canvas)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 14:19 
folgende zeile: Image1.Canvas.Assign(PaintBox1.Canvas); ruft folgenden fehler auf:
Zitat:
Cannot assign a TControlCanvas to a TBitmapCanvas.


und jetzt?
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 20.05.06 14:58 
x_X erm... Dann speichers halt mit einer eigenen instanz eines TBitMapCanvas (oder TControlCanvas). Aber nicht
ausblenden Delphi-Quelltext
1:
2:
3:
var x:TControlCanvas
begin
x:=PaintBox1.Canvas;
denn dabei speicherst du dadrin nur den Speicher des Canvas, du kompierst es nicht hinein. d.h. ale änderungen des PaintBox-Canvas betreffen auch x.
ausblenden Delphi-Quelltext
1:
2:
x:=TControlCanvas.Create;
x.assign(PaintBox1.Canvas);

Ich denke das sollte klappen, ansonsten bin ich mit meinem Latein am ende (*grmbl...*)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 17:14 
ob dus nun glaubst oder nicht aber da kommt doch tatsächlich dieser himmelsschreiende Fehler:

Zitat:
Cannot assign a TControlCanvas to a TControlCanvas.


langsam versteh ich gar nix mehr ey, das kann doch nit sein ey...
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 20.05.06 18:12 
Ok nun ists aus. Nun müssen die Profis ran.. Ich denke da an BenBE, meinen :anfleh: -Gott und GTA-Place und die ganzen Delphi-PGs... naja sagen wir mal so, ich blicks nich mehr. Sorry. Ich hoffe, jemand anders erbarmt sich deiner :D

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: Sa 20.05.06 18:25 
^^
das is schon n bissel ein komisches problem...
aber ich hab folgende lösung: (fast)
also ich nehm ein TImage und setze es über das bild was ich hab mit den gleichen einstellungen aber auf transparent...
dann geht das habs auch soweit schon hinbekommen

aber wenn ich nach dem klicken die maus bewegt wird alles wieder grau...

hier der code: (PaintBox2 ist ein TImage ^^)
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:
32:
33:
procedure TForm1.FormCreate(Sender: TObject);
begin
PaintBox2.Transparent := true;
end;

procedure TForm1.PaintBox2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
clicked:=true;
xbegin:=X;
ybegin:=Y;
end;

procedure TForm1.PaintBox2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if clicked then begin
PaintBox2.Canvas.Pen.Color:=clBtnFace;
PaintBox2.Canvas.Rectangle(xbegin,ybegin,xlast,ylast);
PaintBox2.Canvas.Pen.Color:=clBlack;
PaintBox2.Canvas.Rectangle(xbegin,ybegin,X,Y);
xlast:=X;
ylast:=Y;
end;
end;

procedure TForm1.PaintBox2MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
clicked:=false;
PaintBox2.Canvas.Pen.Color:=clBtnFace;
PaintBox2.Canvas.Rectangle(xbegin,ybegin,xlast,ylast);
end;