我想遍历系统中所有的Internet Explorer窗口
不要用FindWindow查找标题,因为它的标题是可变的~~
最好用别的方法~~~
然后把他们的窗口名称存到一个 StringList 里面~~~
然后我要获取每一个IE窗口的高度,和宽度。
请大家帮忙 UP有分~~
不够分在开贴~~~
不要用FindWindow查找标题,因为它的标题是可变的~~
最好用别的方法~~~
然后把他们的窗口名称存到一个 StringList 里面~~~
然后我要获取每一个IE窗口的高度,和宽度。
请大家帮忙 UP有分~~
不够分在开贴~~~
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, StrUtils;type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;
var
Form1: TForm1;
{$R *.DFM}
implementationprocedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Clear;
EnumWindows(@EnumerateWindows, 0);
end;function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL;
var
TheText: array[0..255] of char;
sIETitle: string;
Rect: Trect;
IeWidth, IeHight: integer;
begin
sIETitle := 'Microsoft Internet Explorer';
if (GetWindowText(hWnd, TheText, 255) = 0) then
// Form1.ListBox1.Items.Add(Format('%d = {This window has no text}', [hWnd]))
else
begin
if AnsiContainsText(TheText, PChar(sIETitle)) then
begin
GetWindowRect(hWnd, rect);
IeHight := rect.Bottom - rect.Top;
IeWidth := rect.Right - rect.Left;
Form1.ListBox1.Items.Add(Format('%d = %s', [hWnd, TheText]) + '|width:' + inttostr(iewidth) + 'high:' + inttostr(iehight));
end;
end;
Result := TRUE;
end;
end.
if (GetWindowText(hWnd, TheText, 255) = 0) then
有什么作用?
我认为应该用IE窗口的类名来查找,好像是IEFrame吧,
记不清了,用SPY++查一下吧
ShellWindow: IShellWindows;
vi: OleVariant;
spDisp: IDispatch;
IDoc1: IHTMLDocument2;
i: integer;
nCount: integer;
IE1: IWebBrowser2;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount-1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
spDisp.QueryInterface( iWebBrowser2, IE1);
if IE1 <> nil then
begin
memo1.Lines.Add(inttostr(IE1.Height)+','+inttostr(IE1.Width));
Memo1.lines.Add(IE1.LocationURL);
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
memo1.Lines.Add(IDoc1.title);
end;
end;
end;
end;
用你的代码找到的窗口
和用窗口类IEFrame查找到的有什么区别吗~~
我象要知道他们的高度和宽度~
HTMLDocument可以对IE全方位控制
上面的程序不但可以得到IE窗口的属性
还可以得到资源管理器窗口的属性
当然
用一楼的方法也不错啊
晚上回去试验~~~只要成功立刻给分~~
那么根据您的代码所列出的窗口
如果用PostMessage该如何关闭这些窗口~~
或者可以用别的方法