Autor Beitrag
Petros
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 131
Erhaltene Danke: 1


Delphi7, Delphi RadStudio 10 Berlin, VSC# 2015, Java 8
BeitragVerfasst: Do 04.10.12 16:05 
Hi delphi freunde ich weiß zwar nicht ob hier richtig fals nein bitte verschieben...

Jetzt zu meinem problem..

Ich will mit Firemonkey ein programm schreiben soweit alles super.
Nun hab ich ein bild (TImage) wenn mann die maus gedrückt hälte und es bewege soll sich die Form mit bewegen.

Mein ansatz war

VLC Anwendung
ausblenden 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:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
bewegen := True;
positionx:=x;
positiony:=y;
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if schieben = True then
begin
  Form1.left := Form1.Left + x - positionx;
  Form1.Top := Form1.Top + y - positiony;
end;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Bewegen := False;
end;


Klappt in einer VLC anwendung super nur mit Firemonkey HD anwendung geht das leider nicht

da X, Y nicht als Integer sondern Single angegeben, ändere ich single in Integer wird diese nicht mehr im ereignisse angegeben.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Single);
begin

end;


Lege ich eine Funktion an und lasse diese dann per MouseUp, MouseMove, MouseDown aufrufen verschwindet die form einfach in den hintergrund.

Ich hoffe es war verständlich ausgedrückt und hoffe Ihr habt evtl ne lösung.

Moderiert von user profile iconNarses: B- gegen highlight-Tag im Code ersetzt.
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 04.10.12 16:19 
ausblenden Delphi-Quelltext
1:
2:
3:
bewegen := True;
positionx:=Round(x);
positiony:=Round(y);


und so weiter ....

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS

Für diesen Beitrag haben gedankt: Petros
Petros Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 131
Erhaltene Danke: 1


Delphi7, Delphi RadStudio 10 Berlin, VSC# 2015, Java 8
BeitragVerfasst: Do 04.10.12 16:44 
Cool danke bummi für alle anderen die etwas ähnliches gesucht haben oder suchen sollten

ausblenden 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:
private
        positionx, positiony  : Integer;

var
  Form1: TForm1;
  Bewegen : Boolean;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
Bewegen := True;
positionx:=Round(x);
positiony:=Round(y);
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Single);
begin
if bewegen = True then
begin
  Form1.left := Form1.Left + Round(x)- positionx;
  Form1.Top :=  Form1.Top + Round(y) - positiony;
end;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
Bewegen := False;
end;
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Do 04.10.12 22:24 
Was mir noch auffällt: Du prüfst in Zeile 112 auf true.
Das ist nicht nur nicht schön, sondern auch falsch. ;)

Bei einer If-Abfrage wird automatisch auf true geprüft, somit prüfst du erstens doppelt.
Zweitens ist true als Konstant 1 definiert. Allerdings kann laut Definition der Rückgabewert von der If-Abfrage bei true alle Werte außer der 0 (false) annehmen.
Im ungünstigen Fall prüfst du also z.B. sowas: 1 <> 2.

Schöne Abend
Marc
Petros Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 131
Erhaltene Danke: 1


Delphi7, Delphi RadStudio 10 Berlin, VSC# 2015, Java 8
BeitragVerfasst: Fr 05.10.12 20:02 
ahh Marc. danke für den hinweiß ich muss dazu sagen das ich vorher mit Delphi 7 Prof gearbeitet habe dann irgendwann letzes jahr auf XE und vor 4 tagen auf XE3 umgestiegen bin naja wie sagt mann so schön alte gewohnheiten kann mann nicht so leicht ablegen aber recht haste