Como Redirecionar Uma URL No I.E 8?

Delphi

25/08/2010

Pessoal, utilizei este código:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure SetUrlFromIE(Handle: THandle); stdcall;
var
  hWndIE, hWndIEChild : HWND;
  Buffer : array[0..255] of Char;
  Url: String;
begin
  Url:= 'http://www.yahoo.com.br';

  // Pega o Caption da Janela
  SendMessage(Handle, WM_GETTEXT, 255, lParam(@Buffer[0]));

  // Procura pela janela do Internet Explorer com o Buffer do Caption
  hWndIE := FindWindow('IEFrame', Buffer);

  If hWndIE > 0 Then
    Begin
      // Pega o Handle do container do Internet Explorer
      hWndIEChild:= FindWindowEx(hWndIE, 0, 'WorkerW', nil);

      If hWndIEChild > 0 Then
        Begin
          // Pega o Handle da Barra de Endereço do Internet Explorer
          hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ReBarWindow32', nil);

          If hWndIEChild > 0 Then
            Begin
              // Pega o Handle do ComboBoxEx32 do Internet Explorer
              hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ComboBoxEx32', nil);

              If hWndIEChild > 0 Then
                Begin
                  // Pega o Handle do ComboBox do Internet Explorer
                  hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ComboBox', nil);

                  If hWndIEChild > 0 Then
                    Begin
                      // Pega o Handle do Edit do Internet Explorer
                      hWndIEChild := FindWindowEx(hWndIEChild, 0, 'Edit', nil);

                      If hWndIEChild > 0 Then
                        Begin
                          // Seta a URL no campo Edit do Internet Explorer
                          SendMessage(hWndIEChild, WM_SETTEXT,  0, lParam(Url));
                          // Simula o precionamento da tecla <Enter>
                          PostMessage(hWndIEChild, WM_KEYDOWN,  $D, $0008044C);
                        End; // Fim - Verifica retorno Edit

                    end; // Fim - Verifica retorno Combo

                end; // Fim - Verifica retorno ComboBoxEx32

            end; // Fim - Verifica retorno ReBarWindow32

        end; // Fim - Verifica retorno WorkerW

    end; // Fim - Verifica retorno IEFrame

end;



procedure TForm1.Timer1Timer(Sender: TObject);
var
Janela : THandle;
begin
Janela := FindWindow(nil, 'UOL - O melhor conteúdo - Windows Internet Explorer');
SetUrlFromIE(Janela);
end;

end.


Esse código pega o caption da janela do site do uol que é: UOL - O melhor conteúdo - Windows Internet Explorer e redireciona para: http://www.yahoo.com.br

Porém não obtive sucesso, peguei esse código em 2006 e o pessoal usava no I.E 6, agora não sei se houve alguma mudança com o I.E 8, Gostaria que alguêm me desse uma ajuda.
Rafael Vagliante

Rafael Vagliante

Curtidas 0
POSTAR