---- 5. 增 加 一 些 新 特 性: 隐 藏/ 显 示/ 关 闭. ---- 增 加2 个 函 数: 用 于 更 新ListBox1. function EnumPRoc( h : HWND ;// handle of child window l : integer// application-defined value ): boolean;stdcall; var buf : array[0..255] of char; begin GetWindowText(h, buf, sizeof(buf)- 1); if iswindowvisible(h) then Form1.ListBox1.items.add(' ' +strpas(buf) + ' : ' + inttostr(h)) else Form1.ListBox1.items.add('-' +strpas(buf) + ' : ' + inttostr(h)); Result := true; end;
procedure TForm1.Fresh1; begin ListBox1.clear; enumChildwindows(Panel2.handle, TFNWndEnumProc(@enumproc), 0); end;
---- 增 加 一 个 弹 出 菜 单Popupmenu1, 3 个 菜 单 项, 'Show, Hide, Close', 将ListBox1.popupmemu 指 向Popupmenu1. ---- Hide 的 处 理 函 数 是: procedure TForm1.Hide1Click(Sender: TObject); var h : integer; s : string; begin if ListBox1.itemindex = -1 then exit; s := Listbox1.items[ListBox1.itemindex]; h := strtoint(copy(s, pos(':', s) + 1, length(s))); ShowWindow(h, SW_HIDE); Fresh1; end;
Show 的 处 理 函 数 是: procedure TForm1.Show1Click(Sender: TObject); var h : integer; s : string; begin if ListBox1.itemindex = -1 then exit; s := Listbox1.items[ListBox1.itemindex]; h := strtoint(copy(s, pos(':', s) + 1, length(s))); ShowWindow(h, SW_SHOW); Fresh1; end;
Close 的 处 理 函 数 是: procedure TForm1.Close1Click(Sender: TObject); var h : integer; s : string; begin if ListBox1.itemindex = -1 then exit; s := Listbox1.items[ListBox1.itemindex]; h := strtoint(copy(s, pos(':', s) + 1, length(s))); PostMessage(h, WM_QUIT, 0, 0); Fresh1; end;
{$R *.DFM} function EnumProc( h : HWND ;// handle of child window l : integer// application-defined value ): boolean;stdcall; var buf : array[0..255] of char; begin GetWindowText(h, buf, sizeof(buf)- 1); if iswindowvisible(h) then Form1.ListBox1.items.add(' ' +strpas(buf) + ' : ' + inttostr(h)) else Form1.ListBox1.items.add('-' +strpas(buf) + ' : ' + inttostr(h)); Result := true; end;
procedure TForm1.Fresh1; begin ListBox1.clear; enumChildwindows(Panel2.handle, TFNWndEnumProc(@enumproc), 0); end;
procedure TForm1.FormCreate(Sender: TObject); var buf : array[0..256] of char; begin GetSystemDirectory(buf, sizeof(buf) - 1); FileListBox1.directory := strpas(buf); ListBox1.popupmenu := Popupmenu1; end;
procedure TForm1.Hide1Click(Sender: TObject); var h : integer; s : string; begin if ListBox1.itemindex = -1 then exit; s := Listbox1.items[ListBox1.itemindex]; h := strtoint(copy(s, pos(':', s) + 1, length(s))); ShowWindow(h, SW_HIDE); Fresh1; end;
procedure TForm1.Show1Click(Sender: TObject); var h : integer; s : string; begin if ListBox1.itemindex = -1 then exit; s := Listbox1.items[ListBox1.itemindex]; h := strtoint(copy(s, pos(':', s) + 1, length(s))); ShowWindow(h, SW_SHOW); Fresh1; end;
procedure TForm1.Close1Click(Sender: TObject); var h : integer; s : string; begin if ListBox1.itemindex = -1 then exit; s := Listbox1.items[ListBox1.itemindex]; h := strtoint(copy(s, pos(':', s) + 1, length(s))); PostMessage(h, WM_QUIT, 0, 0); Fresh1; end;