Einzelnen Beitrag anzeigen

DarkItachi

Registriert seit: 28. Dez 2009
Ort: Berlin
130 Beiträge
 
Delphi 2007 Enterprise
 
#5

Re: [DELPHI 2010] EnumWindows mit Handle

  Alt 4. Feb 2010, 12:32
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    function EnumWindowsProc(wHandle: HWND; lb: TListBox): Bool; stdcall; export;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 EnumWindows(@EnumWindowsProc, Integer(ListBox1));
end;

function TForm1.EnumWindowsProc(wHandle: HWND; lb: TListBox): Bool; stdcall; export;
var
  Title, ClassName: array[0..255] of char;
begin
  Result := True;
  GetWindowText(wHandle, Title, 255);
  GetClassName(wHandle, ClassName, 255);
  if IsWindowVisible(wHandle) then
     lb.Items.Add(string(Title) + '-' + string(ClassName));
end;

end.

Hoffentlich ist das kein dussliger Fehler
Miniaturansicht angehängter Grafiken
unbenannt_748.png  
Angehängte Dateien
Dateityp: zip delphi_777.zip (13,7 KB, 8x aufgerufen)
Developer since age 14
  Mit Zitat antworten Zitat