home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 March
/
Chip_1999-03_cd.bin
/
zkuste
/
delphi
/
D34
/
MSYSINFO.ZIP
/
Demo
/
Main.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1999-01-26
|
27KB
|
1,021 lines
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ExtCtrls, Menus, Buttons, MSysInfo, ImgList, ToolWin, StdCtrls;
type
TInfoMode = (imNode, imText);
TfrmMain = class(TForm)
SB: TStatusBar;
SI: TMSysInfo;
PopupMenu: TPopupMenu;
pmRefresh: TMenuItem;
pmAbout: TMenuItem;
N1: TMenuItem;
pmExit: TMenuItem;
Timer: TTimer;
Panel1: TPanel;
Splitter1: TSplitter;
EmptyPanel: TPanel;
lvSI: TListView;
tvSI: TTreeView;
ImageList: TImageList;
CoolBar1: TCoolBar;
ToolBar: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
ToolButton3: TToolButton;
Panel2: TPanel;
cbTopic: TComboBox;
lcv: TLabel;
procedure cmRefresh(Sender: TObject);
procedure cmAbout(Sender: TObject);
procedure cmExit(Sender: TObject);
procedure cmGetItemData(Sender: TObject; Node: TTreeNode);
procedure FormCreate(Sender: TObject);
procedure TimerTimer(Sender: TObject);
procedure cmExpCol(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure cbTopicChange(Sender: TObject);
procedure cmWinList(Sender: TObject);
private
{ Private declarations }
function GetComputerData(Parent :TTreenode; Mode :TInfoMode; var Node :TTreeNode) :Boolean;
function GetCPUData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetBIOSData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetMemoryData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetDisksData(Parent :TTreenode; Mode :TInfoMode; var Node :TTreeNode) :Boolean;
function GetDiskData(Sign :char; Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetDisplayData(Parent :TTreenode; Mode :TInfoMode; var Node :TTreeNode) :Boolean;
function GetFontsData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetSoundData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetMonitorData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetMouseData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetPrinterData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetOSData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetDBData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetDXData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
function GetNetData(Parent :TTreenode; Mode :TInfoMode) :Boolean;
public
{ Public declarations }
procedure FillSystemInfo;
end;
var
frmMain: TfrmMain;
const
txParameter = 'Property';
txValue = 'Value';
txSpace = '';
txDescription = 'Description';
txComputer = 'Computer';
txName = 'Name';
txOwner = 'Owner';
txOrg = 'Organization';
txUser = 'User';
txIP = 'IP Address';
txBootTime = 'Boot time';
txLastBoot = 'Last boot';
txCPU = 'CPU';
txNumberOfProcessors = 'Number of Processors';
txActiveProcessorMask = 'Active Processor Mask';
txProcessorArchitecture = 'Architecture';
txProcessorType = 'Type';
txProcessorVendor = 'Vendor';
txProcessorVendorID = 'Vendor Identifier';
txProcessorLevel = 'Level';
txProcessorRevision = 'Revision';
txProcessorSpeed = 'Speed';
txBIOS = 'BIOS';
txBIOSName = 'BIOS Name';
txBIOSCopyright = 'BIOS Copyright';
txBIOSDate = 'BIOS Date';
txBIOSExt = 'BIOS Extended Info';
txBIOSVideoVer = 'BIOS Video Version';
txBIOSVideoDate = 'BIOS Video Date';
txMemory = 'Memory';
txMemUsage = 'Usage';
txTotalPhys = 'Total Physical';
txAvailPhys = 'Available Physical';
txTotalPage = 'Total Page File';
txAvailPage = 'Available Page File';
txTotalVirt = 'Total Virtual';
txAvailVirt = 'Available Virtual';
txPageSize = 'Page Size';
txAllocGran = 'Allocation Granularity';
txDisk = 'Disks';
txNumber = 'Number';
txAvailSigns = 'Available Signs';
txFileSystem = 'File System';
txSerial = 'Serial Number';
txCompress = 'Compressed';
txFreeSpace = 'Free Space';
txTotalSpace = 'Total Space';
txTotalClusters = 'Total Clusters';
txSPC = 'Sectors Per Cluster';
txBPS = 'Bytes Per Sector';
txDisplay = 'Display';
txChip = 'Chip';
txDAC = 'DAC';
txVideoMem = 'Memory';
txXRes = 'Screen Width';
txYRes = 'Screen Height';
txRes = 'Color Resolution';
txFontCount = 'Font Count';
txFonts = 'Installed Fonts';
txFontname = 'Font Name';
txSound = 'Sound Device';
txWaveIn = 'Wave In';
txWaveOut = 'Wave Out';
txMIDIIn = 'MIDI In';
txMIDIOut = 'MIDI Out';
txAUX = 'AUX';
txMixer = 'Mixer';
txPrinter = 'Printer';
txMouse = 'Mouse';
txMonitor = 'Monitor';
txDirectX = 'DirectX';
txDXVer = 'Version';
txNetwork = 'Network';
txAdapter = 'Adapter';
txOS = 'Operating System';
txPlatform = 'Platform';
txVersion = 'Version';
txCSD = 'CSD Version';
txMaxApp = 'Maximum Application Address';
txMinApp = 'Minimum Application Address';
txProductID = 'Product ID';
txTimeZone = 'Time Zone';
txDB = 'Database';
txBDE = 'BDE Version';
txODBC = 'ODBC Version';
implementation
{$R *.DFM}
uses
ShellAPI;
var
tvWidth :integer;
function BoolToStr(x :boolean) :string;
begin
if x then
result:='Yes'
else
result:='No';
end;
{###################### Private routines #######################}
function TfrmMain.GetComputerData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
node:=add(parent,txComputer);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=txName;
item.subitems.add(si.cmpname);
item:=items.add;
item.caption:=txOwner;
item.subitems.add(si.osreguser);
item:=items.add;
item.caption:=txOrg;
item.subitems.add(si.osregorg);
item:=items.add;
item.caption:=txIP;
item.subitems.add(si.cmpIPAddress);
item:=items.add;
item.caption:=txSpace;
item:=items.add;
item.caption:=txBoottime;
item.subitems.add(si.cmpboottime);
item:=items.add;
item.caption:=txlastboot;
item.subitems.add(si.cmplastboot);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetCPUData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txCPU);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=txNumberOfProcessors;
item.subitems.add(inttostr(si.cpuNumber));
item:=items.add;
item.caption:=txActiveProcessorMask;
item.subitems.add(inttostr(si.cpuactivemask));
item:=items.add;
item.caption:=txProcessorArchitecture;
item.subitems.add(si.getcpuarc(si.cpuarchitecture));
item:=items.add;
item.caption:=txProcessorType;
item.subitems.add(si.getcputype(si.cputype));
item:=items.add;
item.caption:=txProcessorLevel;
item.subitems.add(inttostr(si.cpulevel));
item:=items.add;
item.caption:=txProcessorRevision;
item.subitems.add(inttostr(si.cpurevision));
item:=items.add;
item.caption:=txProcessorSpeed;
item.subitems.add(inttostr(round(int(si.cpuspeed)))+' MHz');
item:=items.add;
item.caption:=txSpace;
item.imageindex:=-1;
item:=items.add;
item.caption:=txProcessorVendor;
item.subitems.add(si.cpuvendor);
item:=items.add;
item.caption:=txProcessorVendorID;
item.subitems.add(si.cpuvendorid);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetBIOSData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txBIOS);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=txBIOSName;
item.subitems.add(si.biosname);
item:=items.add;
item.caption:=txbioscopyright;
item.subitems.add(si.bioscopyright);
item:=items.add;
item.caption:=txbiosdate;
item.subitems.add(si.biosdate);
item:=items.add;
item.caption:=txbiosext;
item.subitems.add(si.biosextendedinfo);
item:=items.add;
item.caption:=txbiosvideover;
item.subitems.add(si.biosvideoversion);
item:=items.add;
item.caption:=txbiosvideodate;
item.subitems.add(si.biosvideodate);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetDXData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txDirectX);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=txDXVer;
item.subitems.add(si.drxVersion);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetNetData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txNetwork);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=txAdapter;
item.subitems.add(si.netAdapter);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetMemoryData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txMemory);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txmemusage);
item.subitems.add(formatfloat('#,##0 %',si.memMemUsage));
item:=items.add;
item.caption:=(txspace);
item.imageindex:=-1;
item:=items.add;
item.caption:=(txtotalphys);
item.subitems.add(formatfloat('#,##0 B',si.memtotalphys));
item:=items.add;
item.caption:=(txavailphys);
item.subitems.add(formatfloat('#,##0 B',si.memfreephys));
item:=items.add;
item.caption:=(txspace);
item.imageindex:=-1;
item:=items.add;
item.caption:=(txtotalpage);
item.subitems.add(formatfloat('#,##0 B',si.memtotalpagefile));
item:=items.add;
item.caption:=(txavailpage);
item.subitems.add(formatfloat('#,##0 B',si.memfreepagefile));
item:=items.add;
item.caption:=(txspace);
item.imageindex:=-1;
item:=items.add;
item.caption:=(txtotalvirt);
item.subitems.add(formatfloat('#,##0 B',si.memtotalvirtual));
item:=items.add;
item.caption:=(txavailvirt);
item.subitems.add(formatfloat('#,##0 B',si.memfreevirtual));
item:=items.add;
item.caption:=(txspace);
item.imageindex:=-1;
item:=items.add;
item.caption:=(txpagesize);
item.subitems.add(formatfloat('#,##0 B',si.mempagesize));
item:=items.add;
item.caption:=(txallocgran);
item.subitems.add(formatfloat('#,##0 B',si.memallocationgranularity));
finally
items.EndUpdate;
end;
end;
result:=true;
end;
function TfrmMain.GetDisksData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
node:=addchild(parent,txDisk);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txnumber);
item.subitems.add(formatfloat('#,##0 ',si.dskdiskcount));
item:=items.add;
item.caption:=(txavailsigns);
item.subitems.add(si.dskavailabledisks);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetDiskData;
var
item :tlistitem;
begin
si.dsksign:=sign;
result:=si.dsktotalspace<>-1;
if mode=imnode then
with tvsi.items do
addchild(parent,si.dsksign+': ['+si.dskvolumelabel+']...'+si.getmediatype(si.dskmediatype));
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txFileSystem);
item.subitems.add(si.dskfilesystem);
item:=items.add;
item.caption:=(txserial);
item.subitems.add('0x'+inttohex(si.dskserialnumber,16));
item:=items.add;
item.caption:=(txspace);
item.imageindex:=-1;
item:=items.add;
item.caption:=(txcompress);
item.subitems.add(booltostr(si.dskcompressed));
item:=items.add;
item.caption:=(txTotalspace);
item.subitems.add(formatfloat('#,##0 B',si.dsktotalspace));
item:=items.add;
item.caption:=(txfreespace);
item.subitems.add(formatfloat('#,##0 B',si.dskfreespace));
item:=items.add;
item.caption:=(txTotalclusters);
item.subitems.add(formatfloat('#,##0 ',si.dsktotalclusters));
item:=items.add;
item.caption:=(txspc);
item.subitems.add(formatfloat('#,##0 ',si.dsksectorspercluster));
item:=items.add;
item.caption:=(txbps);
item.subitems.add(formatfloat('#,##0 ',si.dskbytespersector));
finally
items.endupdate;
end;
end;
end;
function TfrmMain.GetDisplayData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
node:=addchild(parent,txDisplay);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txAdapter);
item.subitems.add(si.vidAdapter);
item:=items.add;
item.caption:=(txChip);
item.subitems.add(si.vidChip);
item:=items.add;
item.caption:=(txDAC);
item.subitems.add(si.vidDAC);
item:=items.add;
item.caption:=(txVideoMem);
item.subitems.add(formatfloat('#,## KB',si.vidMemory div 1024));
item:=items.add;
item.caption:=(txspace);
item.imageindex:=-1;
item:=items.add;
item.caption:=(txxres);
item.subitems.add(inttostr(si.vidHorzRes));
item:=items.add;
item.caption:=(txyres);
item.subitems.add(inttostr(si.vidVertRes));
item:=items.add;
item.caption:=(txres);
item.subitems.add(inttostr(si.vidcolordepth)+' bit');
item:=items.add;
item.caption:=(txFontcount);
item.subitems.add(inttostr(screen.fonts.count));
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetFontsData;
var
item :tlistitem;
i :integer;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txFonts);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txfontname;
columns[1].caption:=txspace;
for i:=0 to screen.fonts.count-1 do begin
item:=items.add;
item.caption:=(screen.fonts[i]);
end;
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetSoundData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txSound);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txadapter);
item.subitems.add(si.sndAdapter);
item:=items.add;
item.caption:=(txspace);
item.imageindex:=-1;
item:=items.add;
item.caption:=(txwavein);
item.subitems.add(si.sndwavein);
item:=items.add;
item.caption:=(txwaveout);
item.subitems.add(si.sndwaveout);
item:=items.add;
item.caption:=(txmidiin);
item.subitems.add(si.sndmidiin);
item:=items.add;
item.caption:=(txmidiout);
item.subitems.add(si.sndmidiout);
item:=items.add;
item.caption:=(txaux);
item.subitems.add(si.sndaux);
item:=items.add;
item.caption:=(txmixer);
item.subitems.add(si.sndmixer);
finally
items.endupdate;
end;
end;
result:=si.sndadapter<>'?';
end;
function TfrmMain.GetMonitorData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txMonitor);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txDescription);
item.subitems.add(si.monName);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetMouseData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txMouse);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txDescription);
item.subitems.add('');
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetPrinterData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
addchild(parent,txPrinter);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=(txDescription);
item.subitems.add(si.prnName);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetOSData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
add(parent,txOS);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=txPlatform;
item.subitems.add(si.getosname(si.osplatformid));
item:=items.add;
item.caption:=txVersion;
item.subitems.add(si.osversionname+' '+inttostr(si.osmajorversion)+'.'+inttostr(si.osminorversion)+'.'+inttostr(si.osbuildnumber));
item:=items.add;
item.caption:=txCSD;
item.subitems.add(si.oscsdversion);
item:=items.add;
item.caption:=txuser;
item.subitems.add(si.osuser);
item:=items.add;
item.caption:=txproductid;
item.subitems.add(si.osserial);
item:=items.add;
item.caption:=txspace;
item.imageindex:=-1;
item:=items.add;
item.caption:=txMinApp;
item.subitems.add('0x'+inttohex(si.osminapplicationaddress,32));
item:=items.add;
item.caption:=txMaxApp;
item.subitems.add('0x'+inttohex(si.osmaxapplicationaddress,32));
item:=items.add;
item.caption:=txspace;
item.imageindex:=-1;
item:=items.add;
item.caption:=txTimeZone;
item.subitems.add(si.ostimezone);
finally
items.endupdate;
end;
end;
result:=true;
end;
function TfrmMain.GetDBData;
var
item :tlistitem;
begin
if mode=imnode then
with tvsi.items do
add(parent,txDB);
if mode=imtext then
with lvsi do begin
items.BeginUpdate;
try
columns[0].caption:=txparameter;
columns[1].caption:=txvalue;
item:=items.add;
item.caption:=txBDE;
item.subitems.add(si.dbbdeversion);
item:=items.add;
item.caption:=txODBC;
item.subitems.add(si.dbodbcversion);
finally
items.endupdate;
end;
end;
result:=true;
end;
{###################### Public routines #######################}
procedure TfrmMain.FillSystemInfo;
var
i :integer;
n,n1 :ttreenode;
begin
with tvsi.items do begin
clear;
getcomputerdata(getfirstnode,imnode,n1);
getbiosdata(n1,imnode);
getcpudata(n1,imnode);
getmemorydata(n1,imnode);
getdisksdata(n1,imnode,n);
for i:=1 to si.dskdiskcount do
getdiskdata(si.dskavailabledisks[i],n,imnode);
getdisplaydata(n1,imnode,n);
getfontsdata(n,imnode);
getmonitordata(n1,imnode);
getsounddata(n1,imnode);
getprinterdata(n1,imnode);
getdxdata(n1,imnode);
getnetdata(n1,imnode);
getosdata(getfirstnode,imnode);
getdbdata(getfirstnode,imnode);
end;
sb.panels[0].text:=inttostr(tvsi.items.count)+' domains';
end;
{###################### Event routines #######################}
procedure TfrmMain.cmRefresh(Sender: TObject);
begin
tvsi.FullCollapse;
tvsi.hide;
tvsi.items.clear;
tvsi.align:=alleft;
tvsi.left:=0;
tvsi.width:=tvwidth;
si.refresh;
fillsysteminfo;
lvsi.hide;
emptypanel.caption:=datetimetostr(now);
tvsi.show;
end;
procedure TfrmMain.cmAbout(Sender: TObject);
begin
shellabout(Application.MainForm.Handle,pchar(application.title),pchar('Copyright ⌐ 1997-99, MichaL MutL'),application.icon.handle);
end;
procedure TfrmMain.cmExit(Sender: TObject);
begin
close;
end;
procedure TfrmMain.cmGetItemData(Sender: TObject; Node: TTreeNode);
var
visible :boolean;
n :ttreenode;
begin
lvsi.items.clear;
visible:=false;
if cbtopic.itemindex=0 then begin
if node.text=txComputer then
visible:=getcomputerdata(node,imtext,n);
if node.text=txCPU then
visible:=getcpudata(node,imtext);
if node.text=txBIOS then
visible:=getbiosdata(node,imtext);
if node.text=txDirectX then
visible:=getdxdata(node,imtext);
if node.text=txMemory then
visible:=getmemorydata(node,imtext);
if node.text=txDisk then
visible:=getdisksdata(node,imtext,n);
if pos('[',node.text)>0 then
visible:=getdiskdata(node.text[1],node,imtext);
if node.text=txDisplay then
visible:=getdisplaydata(node,imtext,n);
if node.text=txfonts then
visible:=getfontsdata(node,imtext);
if node.text=txsound then
visible:=getsounddata(node,imtext);
if node.text=txmonitor then
visible:=getmonitordata(node,imtext);
if node.text=txprinter then
visible:=getprinterdata(node,imtext);
if node.text=txnetwork then
visible:=getnetdata(node,imtext);
if node.text=txOS then
visible:=getosdata(node,imtext);
if node.text=txDB then
visible:=getDBdata(node,imtext);
end;
lvsi.visible:=visible;
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
tvwidth:=tvsi.width;
cbtopic.itemindex:=0;
cbtopicchange(sender);
lcv.caption:=si.about;
end;
procedure TfrmMain.TimerTimer(Sender: TObject);
begin
if not lvsi.visible then
emptypanel.caption:=datetimetostr(now);
end;
procedure TfrmMain.cmExpCol(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ssctrl in shift then begin
if key in [vk_next,vk_numpad3] then begin
ttreeview(sender).hide;
ttreeview(sender).fullexpand;
ttreeview(sender).show;
end;
if key in [vk_prior,vk_numpad9] then
ttreeview(sender).fullcollapse;
end;
end;
procedure TfrmMain.cbTopicChange(Sender: TObject);
begin
case cbtopic.itemindex of
0: cmrefresh(sender);
1: cmwinlist(sender);
end;
end;
procedure TfrmMain.cmWinList(Sender: TObject);
var
n :integer;
cn,wt :string;
wh :hwnd;
root :ttreenode;
p :pchar;
procedure EnumChildWins(Awh :hwnd; ARoot :ttreenode);
var
node :ttreenode;
begin
while awh<>0 do begin
getclassname(awh,p,n);
cn:=strpas(p);
getwindowtext(awh,p,n);
wt:=strpas(p);
node:=tvsi.items.addchild(aroot,'Window '+inttohex(awh,8)+' "'+wt+'" :'+cn);
if iswindowvisible(awh) then
node.imageindex:=5
else
node.imageindex:=4;
node.selectedindex:=node.imageindex;
enumchildwins(getwindow(awh,GW_CHILD),node);
awh:=getwindow(awh,GW_HWNDNEXT);
end;
end;
begin
if tvsi.align=alleft then
tvwidth:=tvsi.width;
tvsi.align:=alclient;
n:=255;
p:=stralloc(n);
wh:=getdesktopwindow;
getclassname(wh,p,n);
cn:=strpas(p);
getwindowtext(wh,p,n);
wt:=strpas(p);
tvsi.FullCollapse;
tvsi.hide;
tvsi.items.clear;
root:=tvsi.items.add(nil,'Window '+inttohex(wh,8)+' "'+wt+'" :'+cn);
enumchildwins(getwindow(wh,GW_CHILD),root);
tvsi.fullexpand;
tvsi.items[0].makevisible;
tvsi.selected:=tvsi.items[0];
tvsi.show;
sb.panels[0].text:=inttostr(tvsi.items.count)+' windows';
end;
end.