1, in order to model the form way, pop-up a child form; 2, when the mouse moves on child form, will be the location of the mouse, the window location and the current time, in the form of news (synchronous) shown in the main form of Caption; Knowledge: use sendmessage send record structure,
CodePudding user response:
Suggest using PostMessage method, need not blocked, the message can use LParam to pass a pointer to the structure of, however, since it is the same process, can also direct access to the main body of the Handle and then send the SetWindowText message displayed directly
CodePudding user response:
The unit Unit1;
Interface
USES the Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls;
Type TForm1=class (TForm) Label1: TLabel; For: TButton; Procedure Button1Click (Sender: TObject); Private {Private declarations} Public {Public declarations} end;
Var Form1: TForm1;
Implementation
{$R *. DFM}
USES the Unit2.
Procedure TForm1. Button1Click (Sender: TObject); The begin Form1Handle:=Self. Handle; Form2. ShowModal; end;
End.
The unit Unit2.
Interface
USES the Windows, Messages, SysUtils, Classes, Graphics, Controls, and Forms;
Procedure TForm2. FormMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); Var S: a String; The begin S:=Format (' Mouse: [] % d, % d, Form2: [% d, % d, % d, % d], Time: ', [X, Y, Left, Top, Width, Height)); S:=S + FormatDateTime (' yyyy - mm - dd_hh: nn: ss ', Now); SetWindowText (Form1Handle, PChar (S)); end;
End.
CodePudding user response:
Supermantm, hello, how can I make a mistake? Really depressed! Appear the following error: Undeclared identifier: 'Form1Handle', in addition the key is to use: use sendmessage send record structure,