gpt4 book ai didi

delphi - 如何关闭ie8标签页

转载 作者:行者123 更新时间:2023-12-03 15:10:50 25 4
gpt4 key购买 nike

下面的代码不会关闭 Internet Explorer 8 中的选项卡。如果我将 wm_close 命令发布到 Wnd,它将关闭 Internet Explorer,但我想关闭当前选项卡而不是整个“ieframe”。 FindWindowEX(Wnd , 0, 'Frame Tab', nil) 是否应该重新调整 ie 框架的句柄?如果是,为什么它不关闭 Internet Explorer 中的当前选项卡?

var
Wnd, WndChild : hwnd;
begin
Wnd := FindWindow('IEFrame', nil);
WndChild := FindWindowEX(Wnd, 0, 'Frame Tab', nil);
postmessage(WndChild, wm_close, 0, 0);
end;

最佳答案

您错过了 1 层,即选项卡本身,除此之外,一切都很好..

var
Wnd, WndChild: THandle;
begin
Wnd := FindWindow('IEFrame', nil); // Top most IE
if Wnd > 0 then
begin
WndChild := FindWindowEx(Wnd, 0, 'Frame Tab', nil); // Tabs holder
if WndChild > 0 then
begin
WndChild := FindWindowEX(WndChild, 0, 'TabWindowClass', nil); // top most tab
if WndChild > 0 then
if PostMessage(WndChild, WM_CLOSE, 0, 0) then
ShowMessage('Close request succeeded...')
else
ShowMessage('Failed!');
end
else
// not tabbed, close IE
if PostMessage(Wnd, WM_CLOSE, 0, 0) then
ShowMessage('Close request succeeded...')
else
ShowMessage('Failed!');
end
else
ShowMessage('No IE');
end;

关于delphi - 如何关闭ie8标签页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2839063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com