Autor Beitrag
alexschultze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 317



BeitragVerfasst: Sa 14.12.02 11:24 
hiho.

ich will meine Form verschieben. Hab da auch folgenden Code:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin


 if Button = mbLeft then  { Nur ziehen, wenn linke Maustaste gedrückt ist }
         form1.BeginDrag(false);  { Wenn ja, dann ziehen }


end;


Das geht aba irgendwie nett. 'Eine Form kann nicht verschoben werden'. ?!?[/code]
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Sa 14.12.02 11:33 
Hi, versuchs mal hiermit:

ausblenden volle Höhe 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:
type
  TForm1 = class(TForm)
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    procedure WmNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

//...

procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);
begin
  DefaultHandler(Msg);
  if Msg.Result = HTCLIENT then
  begin
    Msg.Result := HTCAPTION;
  end;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if (ssLeft in Shift) then
  begin
    ReleaseCapture;
    SendMessage(Form1.Handle,WM_SYSCOMMAND,SC_MOVE+1,0);
  end;
end;

_________________
Viele Grüße
Jakob
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Sa 14.12.02 11:37 
Hi
ich glaub nicht, dass das mit Drag funktioniert. Wenn du die Form einfach nur aufm Bildschirm rumschieben willst könntest du dir eine globale Variable vom Typ Boolean anlegen.
Bei MouseDown wird sie auf True gesetzt, bei MouseUp auf False. Im MouseMove Ereignis wertest du sie dann aus. Wenn True wird die aktuelle Mouseposition mit ClientToScreen die Position der linken, obere Fensterecke ermittelt und anschliessend den Eigenschaften Top und Left zugewiesen.
Ich weiss nicht hundertpro ob's so funktioniert, aber müsste eigentlich gehen.

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
alexschultze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 317



BeitragVerfasst: Sa 04.01.03 21:22 
also DeCodeGuru hatte schon mal ne gute Lösung!
Aber ich verstehe nicht wieso
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
 procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest); 
begin 
  DefaultHandler(Msg); 
  if Msg.Result = HTCLIENT then 
  begin 
    Msg.Result := HTCAPTION; 
  end; 
end;

benötigt wird?

Bei mir geht es auch ohne?!? Und auf ner anderen Form aber geht es gar nett
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Sa 04.01.03 21:35 
du kannst diesen code in irgendein mousedown event reinschreiben

und statt form1 kannst du auch panel1 oder so reinschreiben, sodas du dann ein panel bewegst

ReleaseCapture;
Form1.perform(WM_SysCommand, $F012, 0);

:wink:
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Sa 04.01.03 21:43 
achja, damit kannst du auf ein panel beispielsweise raufklicken (gedr. halten) und damit ein 2. panel verschieben, geht alles :wink:
ich denke mal das der code der einfachste ist.