Autor Beitrag
MasterHiggins
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 26.02.03 11:57 
Hallo,

ich habe eine Form bei der ich BorderStyle auf bsNone gesetzt habe.
Nun will ich aber erreichen, dass man wenn man die Maustaste auf dieser Form gedrückt hält die Form verschieben kann.

Wie geht das??
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 26.02.03 12:05 
ausblenden 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:
var
  Form1: TForm1;
  m    : TPoint;
  d    : Boolean = False;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if Button = (mbLeft) then
 begin
 d := True;
 m.x := x;
 m.y := y;
 end;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if not d then Exit;
Form1.Left := Form1.Left + x - m.x;
Form1.Top := Form1.Top + y - m.y;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
d := False;
end;
mars
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 238

Debian Woody, Win 2000, Win XP
D7 Ent, Kylix 3
BeitragVerfasst: Mi 26.02.03 12:06 
Okay, Luckie kam mir zuvor...
MasterHiggins Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 26.02.03 13:16 
Sehr cool,

das ist das was ich gesucht habe und dann sogar so unkompliziert, dass sogar ich das verstehe!


Danke

Aber noch eine Frage dazu:

Ich habe die Form1 mit einem Image drauf (von einem Organiser) und eine Form2 die dann quasi das Display des Organisers ist (also deutlich kleiner). Wenn ich jetzt aber bei Form1.Activate sage form2.show, dann geht das mit dem Verschieben nicht mehr. Ich will aber auch nicht erst Form2 und dann Form1 aufrufen weil ich dann nachher das selbe Problem andersrum habe. Wie kann ich das Problem lösen?

Danke
MasterHiggins Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 26.02.03 13:46 
Habe es dann sogar doch noch selbst rausgefunden, war nur ein Denkfehler:

Habe bei form2.activate form1.show gesagt, muß das natürlich bei form2.create sagen, weil sonst gibt es ne "Endloschleife" (wenn form2 das Hauptformular ist).
FD-83
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Mi 26.02.03 15:24 
Noch einfacher gehts so:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const  
  SC_DRAGMOVE = $F012;
begin
  if Button = mbleft then 
  begin 
    ReleaseCapture;
    self.Perform(WM_SYSCOMMAND, SC_DRAGMOVE, 0);
  end; 

end;