powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Сделать активной нужную закладку Internet Explorer
1 сообщений из 1, страница 1 из 1
Сделать активной нужную закладку Internet Explorer
    #39780503
Петр
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Как активировать нужную (с нужной строкой адреса) закладку Iexplorer-a?

Код: pascal
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;

...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Сделать активной нужную закладку Internet Explorer
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]