unit UntMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, StdCtrls, WndProcHooks;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses untMDI;
procedure TForm1.Button1Click(Sender: TObject);
var MdiForm: TMDIChild;
begin
MDiForm:=TMDIChild.Create(Application);
MDiForm.Show;
end;
end.
unit untMDI;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, wndProcHooks;
type
TMDIChild = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
bNewMessage: boolean;
procedure ISWndProc(Control: TControl; var Message: TMessage;OrgWndProc: TWndMethod);
public
{ Public-Deklarationen }
end;
var
MDIChild: TMDIChild;
implementation
{$R *.DFM}
procedure TMDIChild.ISWndProc(Control: TControl; var Message: TMessage;
OrgWndProc: TWndMethod);
begin
OrgWndProc(Message);
with Message do
begin
if (msg=WM_LBUTTONDOWN)
or (msg=WM_LBUTTONUP)
or (msg=WM_LBUTTONDBLCLK)
or (msg=WM_RBUTTONDOWN)
or (msg=WM_RBUTTONUP)
or (msg=WM_RBUTTONDBLCLK)
then
begin
ShowMessage('Hallo! FormHandle='+IntToStr(Self.Handle));
bNewMessage:=true;
end;
end;
end;
procedure TMDIChild.FormCreate(Sender: TObject);
var Index: integer;
begin
for Index := 0 to ControlCount - 1 do
WndProcList.HookControl(Controls[Index], ISWndProc);
end;
procedure TMDIChild.FormDestroy(Sender: TObject);
begin
WndProcList.ClearFromOwner(Self);
end;
procedure TMDIChild.Button1Click(Sender: TObject);
begin
ShowMessage('Button1.Click');
end;
end.