home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
delphi
/
tenpack.lzh
/
DEMOSB.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-05-16
|
4KB
|
167 lines
unit demosb;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Grids, StdCtrls, Buttons, Pssbclas, ExtCtrls;
type
TForm1 = class(TForm)
Subclass1: TSubclass;
BitBtn1: TBitBtn;
StringGrid1: TStringGrid;
BitBtn2: TBitBtn;
Label1: TLabel;
BitBtn3: TBitBtn;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; Col, Row: Longint;
var CanSelect: Boolean);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure Subclass1SysEvent(const msg: TMessage; var handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
gridrow : integer;
gridcol : integer;
SubclassedhWnd : THandle;
function fillgrid(hwnd:THandle;lparam:longint):longint;export;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
stringgrid1.options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine];
gridrow := 0;
gridcol := 0;
Stringgrid1.cells[gridcol,gridrow] := 'hWnd';
inc(gridcol);
Stringgrid1.cells[gridcol,gridrow] := 'Window';
end;
function fillgrid(hwnd:THandle;lparam:longint):longint;
var
i : integer;
P : array[0..255] of char;
S : string;
nsize : integer;
l : longint;
begin
nsize := sizeof(P);
If IsWindow(hwnd) then
begin
If form1.Stringgrid1.rowcount < gridrow then
form1.stringgrid1.rowcount := form1.stringgrid1.rowcount + 1;
i := GetWindowtext(hwnd,P,nsize);
if i > 0 then
begin
S := StrPas(P);
gridcol := 0;
form1.stringgrid1.cells[gridcol,gridrow] := inttostr(hwnd);
gridcol := 1;
form1.stringgrid1.cells[gridcol,gridrow] := S;
inc(gridrow);
application.processmessages;
end;
end;
fillgrid := 1;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
l : longint;
enumerated : boolean;
i : integer;
j : integer;
begin
for i := 1 to stringgrid1.rowcount - 1 do
begin
for j := 1 to stringgrid1.colcount - 1 do
stringgrid1.cells[j,i] := '';
end;
gridrow := 1;
gridcol := 0;
enumerated := EnumWindows(TFarProc(@FillGrid),l);
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; Col, Row: Longint;
var CanSelect: Boolean);
begin
if col = 1 then
canselect := false
else
begin
SubclassedhWnd := strtoint(Stringgrid1.cells[col,row]);
label1.caption := 'Subclass: '+stringgrid1.cells[1,row];
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if IsWindow(SubclassedhWnd) then
begin
subclass1.WndHandle := SubclassedhWnd;
subclass1.Hook;
end
else
ShowMessage('No window has been selected');
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
Subclass1.Unhook;
panel2.caption := '';
panel3.caption := '';
panel4.caption := '';
label1.caption := 'Subclassing stopped';
end;
procedure TForm1.Subclass1SysEvent(const msg: TMessage;
var handled: Boolean);
var
M : String;
begin
with Msg do
begin
case Msg of
WM_COMMAND : M := 'WM_COMMAND';
WM_SYSCOMMAND : M := 'WM_SYSCOMMAND';
WM_MOUSEMOVE : M := 'WM_MOUSEMOVE';
WM_LBUTTONDOWN : M := 'WM_LBUTTONDOWN';
WM_LBUTTONUP : M := 'WM_LBUTTONUP';
WM_RBUTTONUP : M := 'WM_RBUTTONUP';
WM_RBUTTONDOWN : M := 'WM_RBUTTONDOWN';
WM_NCHITTEST : M := 'WM_NCHITTEST';
WM_NCLBUTTONDOWN : M := 'WM_NCLBUTTONDOWN';
WM_NCLBUTTONUP : M := 'WM-NCLBUTTONUP';
WM_NCRBUTTONDOWN : M := 'WM_NCRBUTTONDOWN';
WM_NCRBUTTONUP : M := 'WM_NCRBUTTONUP';
WM_SETCURSOR : M := 'WM_SETCURSOR';
WM_WINDOWPOSCHANGING : M:='WM_WINDOWPOSCHANGING';
WM_WINDOWPOSCHANGED : M:='WM_WINDOWPOSCHANGED';
WM_MOVE : M:='WM_MOVE';
WM_SIZE : M:='WM_SIZE';
else
M := 'Other';
end;
panel2.caption := M;
panel3.caption := 'wParam: '+inttostr(wParam);
panel4.caption := 'lParam: '+inttostr(lParam);
end;
end;
end.