|
Сделать активной нужную закладку Internet Explorer
#39780503
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
Ссылка на профиль пользователя:
|
Участник
Откуда: Москва
Сообщения: 812
|
|
Как активировать нужную (с нужной строкой адреса) закладку Iexplorer-a?
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57.
procedure SetIExplorerURL(Sender: TObject; URL : string);
var
Winds: IShellWindows;
IEWB: IWebBrowser2;
i: integer;
Doc: IHtmlDocument2;
Flags: Olevariant;
sf: string;
aHDL: Integer;
pvaClsid, pvarShow, pvarSize: OleVariant;
begin
try
try
Winds := CoShellWindows.Create;
Flags := $0800; //navOpenInNewTab = 0x0800
sf := StringReplace(URL, 'https://', '', [rfReplaceAll, rfIgnoreCase]);
if Winds.Count > 0 then
begin
for i:=0 to Winds.Count - 1 do
if (Winds.Item(i) as IWEbBrowser2).Document <> nil then
begin
IEWB := Winds.Item(i) as IWEbBrowser2;
aHDL := IEWB.Get_HWND;
if IEWB.Document.QueryInterface(IhtmlDocument2, Doc) = S_OK then
begin
if (pos(URL, Doc.url) > 0) then // нужная закладка найдена
begin
//MessageDlg('Экземпляр Internet Explorer уже запущен. ', mtInformation, [mbOk], 0);
// делаем активным Internet Explorer
SetForegroundWindow(aHDL);
ShowWindow(aHDL, SW_SHOWMAXIMIZED);
// ??? нужно сделать активным закладку с найденным адресом
//SetActiveWindow(aHDL); - не работает
break;
end;
end;
end;
end
else
begin
IEWB := CoInternetExplorer.Create;
IEWB.Visible := True;
IEWB.Navigate(URL, Flags,EmptyParam,EmptyParam,EmptyParam);
end;
except
on E: Exception do
MessageDlg('Ошибка открытия Internet Explorer...' + #13#10 +
'___________________________________________________________________________'#13#10 +
E.Message, mtError, [mbOK], 0 );
end;
finally
Doc := nil;
IEWB := nil;
end;
|
|
|