Responda se conseguir - Windows API
18/02/2003
0
Ola Pessoal.
O código abaixo traz todas as janelas abertas visiveis e que não tem pai(Parent), mas ele também traz as janelas tipo POPUP, que estão no SysTray, para constatar isso rode seu programa com essa rotina e vc verá um Project1 e um Form1, ambos se relacionam ao mesmo programa. Gostaria de listar apenas as janelas principais com o Alt+Tab faz, se alguem por me ajudar eu agradeço desde já.
function EnumWindowsProc(Wnd : HWnd;Form : TForm1) : Boolean; Export; {$ifdef Win32} StdCall; {$endif}
var
Buffer : Array[0..99] of char;
begin
GetWindowText(Wnd,Buffer,100);
if IsWindowVisible(Wnd) and (GetParent(Wnd) = 0) and (StrLen(Buffer) <> 0) then
Form.ListBox1.Items.Add(StrPas(Buffer));
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@EnumWindowsProc,LongInt(Self));
end;
Stéfano Santos - stefano@fc.unesp.br
O código abaixo traz todas as janelas abertas visiveis e que não tem pai(Parent), mas ele também traz as janelas tipo POPUP, que estão no SysTray, para constatar isso rode seu programa com essa rotina e vc verá um Project1 e um Form1, ambos se relacionam ao mesmo programa. Gostaria de listar apenas as janelas principais com o Alt+Tab faz, se alguem por me ajudar eu agradeço desde já.
function EnumWindowsProc(Wnd : HWnd;Form : TForm1) : Boolean; Export; {$ifdef Win32} StdCall; {$endif}
var
Buffer : Array[0..99] of char;
begin
GetWindowText(Wnd,Buffer,100);
if IsWindowVisible(Wnd) and (GetParent(Wnd) = 0) and (StrLen(Buffer) <> 0) then
Form.ListBox1.Items.Add(StrPas(Buffer));
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@EnumWindowsProc,LongInt(Self));
end;
Stéfano Santos - stefano@fc.unesp.br
Anonymous
Curtir tópico
+ 0
Responder
Posts
18/02/2003
Nildo
Aqui vai a rotina:
//****************************
Function EnumWindowsProc (Wnd: HWND; lb: TListbox): Boolean;
var caption: Array [0..128] of Char;
begin
Result := True;
if IsWindowVisible(Wnd) and
((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
(HWND(GetWindowLong(Wnd, GWL_HWNDPARENT)) = GetDesktopWindow))and
((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)
then
begin
SendMessage( Wnd, WM_GETTEXT, Sizeof(caption),integer(@caption));
lb.Items.AddObject( caption,TObject( Wnd ));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows( @EnumWindowsProc, integer( listbox1 ));
end;
//************************
Falows
//****************************
Function EnumWindowsProc (Wnd: HWND; lb: TListbox): Boolean;
var caption: Array [0..128] of Char;
begin
Result := True;
if IsWindowVisible(Wnd) and
((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
(HWND(GetWindowLong(Wnd, GWL_HWNDPARENT)) = GetDesktopWindow))and
((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)
then
begin
SendMessage( Wnd, WM_GETTEXT, Sizeof(caption),integer(@caption));
lb.Items.AddObject( caption,TObject( Wnd ));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows( @EnumWindowsProc, integer( listbox1 ));
end;
//************************
Falows
Responder
Clique aqui para fazer login e interagir na Comunidade :)