Autor Beitrag
Gosa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Fr 17.06.05 17:51 
Hallo,

Ich erstelle per Knopfdruck eine Form die wenn sie verschoben wird etwas bestimmtes machen soll. Aber wie weise ich der Form diese Procedure zu?

Das habe ich bisher:
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:
type
  TWMMoving = record
    Msg: Cardinal;
    fwSide: Cardinal;
    lpRect: PRect;
    Result: Integer;
  end;

var
 FForm : TForm;

Procedure OnFormMoving(var Msg: TWMMoving); message WM_MOVING;

procedure Button1Click(Sender: TObject);
begin
  FForm := TForm.Create(nil);
  FForm.Parent := Self;

  FForm.OnFormMoving := OnFormMoving; //das geht natürlich nicht aber was muss ich da machen?
end;

procedure TFileSendChoose.OnFormMoving(var Msg: TWMMoving);
Begin
  //mach was
End;
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 17.06.05 17:53 
SO weit ich weiß wird die Procedure fürs bewegen (WM_...MOVING) direkt aufgerufen. da musst du nix mehr verlinken
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 17.06.05 17:56 
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:
type
  TWMMoving = record
    Msg: Cardinal;
    fwSide: Cardinal;
    lpRect: PRect;
    Result: Integer;
  end;

type
  FForm = class(TForm)
  private
    Procedure OnFormMoving(var Msg: TWMMoving); message WM_MOVING;
  end;

var
 FForm : TFForm;


procedure Button1Click(Sender: TObject);
begin
  FForm := TForm.Create(nil);
  FForm.Parent := Self;
end;

procedure TFileSendChoose.OnFormMoving(var Msg: TWMMoving);
Begin
  //mach was
End;

zwar nicht mehr so recht dynamisch erzeugt, und ungetestet, so sollte das aber glaube ich sein (nee funzt net recht :lol:)


Zuletzt bearbeitet von F34r0fTh3D4rk am Fr 17.06.05 17:57, insgesamt 1-mal bearbeitet
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 17.06.05 17:57 
user profile iconalias5000 hat folgendes geschrieben:
SO weit ich weiß wird die Procedure fürs bewegen (WM_...MOVING) direkt aufgerufen. da musst du nix mehr verlinken


Jep. Das wäre in deinem Beispielquelltext z.B.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TFileSendChoose.OnFormMoving(var Msg: TWMMoving);
Begin
  ShowMessage('Hör auf, mich rumzuschieben!');
End;


;) AXMD
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Fr 17.06.05 18:20 
Bei mir geht das nicht. Was mach ich da falsch? (Danke für die schnellen Antworten)

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:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TWMMoving = record
    Msg: Cardinal;
    fwSide: Cardinal;
    lpRect: PRect;
    Result: Integer;
  end;

  TForm2 = class(TForm)
  private
    Procedure OnFormMoving(var Msg: TWMMoving); message WM_MOVING;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1 : TForm1;
  Form2 : TForm2;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2 := TForm2.Create(nil);
  Form2.Parent := Form1;
  Form2.Visible := true;
end;

procedure TForm2.OnFormMoving(var Msg: TWMMoving);
Begin   
   ShowMessage('Hör auf, mich rumzuschieben!');
End;

end.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 17.06.05 18:27 
Sicher, dass du Form2 schiebst und nicht Form1?

AXMD
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Fr 17.06.05 18:29 
Soweit komm ich gar nicht... Wenn ich auf den Button drücke sagt mir Delphi: 'Resource TForm2 wurde nicht gefunden'
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 17.06.05 18:35 
Du erzeugst sie IMHO auch falsch...

ausblenden Delphi-Quelltext
1:
2:
Application.CreateForm(TForm2, Form2);
Form2.Show;


AXMD
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Fr 17.06.05 18:37 
Der sagt leider immer noch dasselbe.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 17.06.05 18:42 
Im implementation-Teil fehlt das uses Unit2; und die zweite Formular-Ressource (mit {$R *.DFM} bindest du ja nur die DFM-Datei von Form1 ein...

AXMD
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Fr 17.06.05 18:48 
user profile iconAXMD hat folgendes geschrieben:
Im implementation-Teil fehlt das uses Unit2; und die zweite Formular-Ressource (mit {$R *.DFM} bindest du ja nur die DFM-Datei von Form1 ein...

AXMD


Ich wusste nie wofür das {$R *.DFM} da ist. :)

Und was ich da jetzt ganau machen muss weiss ich leider auch nicht. :(
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 17.06.05 19:22 
Sag mal kann es sein, dass du Form2 einfach nur definiert hast, es aber gar kein Formular dazu gibt :gruebel:

AXMD
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Sa 18.06.05 10:28 
Ja, ich will ja mehrere davon zur Laufzeit erstellen können.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Sa 18.06.05 10:50 
Dann ist klar, dass das nicht geht. Das musst du komplett anders machen - woher soll den Delphi die DFM-Dateien nehmen, wenn du keine hast?

AXMD
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: So 19.06.05 11:23 
Ich wusste nicht das delphi sowas braucht... Denn normale Formen kann man ja ohne erstellen. Aber wie geht denn das anders?
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: So 19.06.05 11:33 
user profile iconGosa hat folgendes geschrieben:
Ich wusste nicht das delphi sowas braucht... Denn normale Formen kann man ja ohne erstellen. Aber wie geht denn das anders?


Datei -> Neu -> Formular

AXMD
Gosa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mo 20.06.05 13:53 
Ok klappt :) Vielen Dank