Oma*_*bal 5 delphi winapi internet-explorer-8
下面的代码没有关闭Internet Explorer 8中的选项卡.如果我将Wm_close命令发布到Wnd,它会关闭Internet Explorer,但我想关闭当前选项卡而不是整个'ieframe'.FindWindowEX(Wnd,0,'Frame Tab',nil)是否应该重新设置一个句柄即框架?如果是,为什么不关闭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;
Run Code Online (Sandbox Code Playgroud)
你错过了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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2748 次 |
| 最近记录: |