unit Main.View;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 =
class( TForm )
ListBox1 : TListBox;
procedure FormDestroy( Sender : TObject );
procedure FormCreate( Sender : TObject );
private
public
end;
var
Form1 : TForm1;
implementation
type
TMyCallBack =
procedure( nCode : Integer; WPARAM : WPARAM; LPARAM : LPARAM );
stdcall;
function InstallHook( CallBack : TMyCallBack ) : Boolean;
stdcall;
external '
HookCallWndProc.dll';
function UninstallHook( ) : Boolean;
stdcall;
external '
HookCallWndProc.dll';
{$R *.dfm}
procedure HookCallWndProc( nCode : Integer; WPARAM : WPARAM; LPARAM : LPARAM );
stdcall;
var
cwps : TCWPStruct;
szClass :
array [0 .. 80]
of Char;
begin
if nCode = HC_ACTION
then
begin
CopyMemory( @cwps, Pointer( LPARAM ), SizeOf( CWPSTRUCT ) );
GetClassName( cwps.hwnd, szClass, Length( szClass ) - 1 );
case cwps.
message of
WM_WINDOWPOSCHANGING :
begin
Form1.ListBox1.ItemIndex := Form1.ListBox1.Items.Add( '
WINDOWSPOSCHANGING ' + szClass );
end;
end;
end;
end;
procedure TForm1.FormCreate( Sender : TObject );
begin
InstallHook( HookCallWndProc );
end;
procedure TForm1.FormDestroy( Sender : TObject );
begin
UninstallHook;
end;
end.