Mega Code Archive

 
Categories / Delphi / System
 

Handle list show-hide

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type EnumWindowsProc = function (Hwnd : THandle;Param:Pointer):Boolean;stdcall; TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; ComboBox1: TComboBox; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function GetTitle(Hwnd : THandle;Param:Pointer):Boolean;stdcall; var Text : string; begin SetLength(Text,100); GetWindowText(Hwnd,Pchar(Text),100); Form1.ComboBox1.Items.Add(Text); GetTitle := True; Form1.Label1.Caption := IntToStr(Form1.ComboBox1.Items.Count); end; procedure TForm1.Button1Click(Sender: TObject); begin Windows.ShowWindow(FindWindow(nil,PChar(ComboBox1.Text)),SW_SHOW); end; procedure TForm1.Button2Click(Sender: TObject); begin Windows.ShowWindow(FindWindow(nil,PChar(ComboBox1.Text)),SW_HIDE); end; procedure TForm1.Button3Click(Sender: TObject); begin Close; end; procedure TForm1.FormCreate(Sender: TObject); var WindowProc : EnumWindowsProc; begin ComboBox1.Items.Clear; WindowProc := GetTitle; EnumWindows(@WindowProc,0); end; procedure TForm1.Button4Click(Sender: TObject); var WindowProc : EnumWindowsProc; begin ComboBox1.Items.Clear; WindowProc := GetTitle; EnumWindows(@WindowProc,0); end; end.