whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

37 Visitors Online


 
...show a list of all Internet Explorer windows?
Autor: Rm.
[ Print tip ]  

Tip Rating (6):  
     


//I did it once for my friend, so I post it here.
//Create new app. and on main form add 1 button and 1 listview.

unit Unit1;

interface

uses
  
Windows, Messages, SysUtils, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, ComCtrls;

type
  
TForm1 = class(TForm)
    Button1: TButton;
    ListView1: TListView;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure ListView1DblClick(Sender: TObject);
  private
    
{ Private declarations }
  
public
    
{ Public declarations }
  
end;

var
  
Form1: TForm1;

implementation

{$R *.DFM}


function GetText(WinHandle: THandle): string;
var 
  
P: array[0..256] of Char;
begin
  
P[0] := #0;
  GetWindowText(WinHandle, P, 255);
  if P[0] = #0 then Result := ''
  else 
    
Result := P;
end;

procedure TForm1.Button1Click(Sender: TObject);
var 
  
Hx: THandle;
  P: array[0..256] of Char;
  Item: TListItem;
begin
  
ListView1.Items.Clear;
  Hx := FindWindow(nilnil);
  GetClassName(Hx, P, SizeOf(P));
  if string(P) = 'IEFrame' then
  begin
    
Item := ListView1.Items.Add;
    Item.SubItems.Add(IntToStr(Hx));
    Item.Caption := GetText(Hx);
  end;
  while Hx <> 0 do
  begin
    
Hx := GetWindow(Hx, GW_HWNDNEXT);
    GetClassName(Hx, P, SizeOf(P));
    if string(P) = 'IEFrame' then
    begin
      
Item := ListView1.Items.Add;
      Item.SubItems.Add(IntToStr(Hx));
      Item.Caption := GetText(Hx);
    end;
  end;
end;

procedure TForm1.ListView1DblClick(Sender: TObject);
begin
  with 
(Sender as TListView) do
  begin
    if 
Selected <> nil then
    begin
      
PostMessage(StrToInt(Selected.SubItems[0]), WM_CLOSE, 0, 0);
      Selected.Delete;
    end;
  end;
end;

end.


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners