Показать сообщение отдельно
  #2  
Старый 08.12.2010, 13:04
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

да, конечно:

Код:
unit Unit1;

interface

uses
  MSHTML,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    WebBrowser: TWebBrowser;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses MSXML2_TLB;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  document: OleVariant;
  stringlist: TStringList;
begin
  WebBrowser.Navigate('about:blank');
  while WebBrowser.ReadyState<READYSTATE_INTERACTIVE do
    Application.ProcessMessages;
  stringlist:=TStringList.Create;
  try
    stringlist.LoadFromFile('test.htm');
    document:=WebBrowser.Document;
    document.clear;
    document.open;
    document.write(stringlist.Text);
    document.close;
    while WebBrowser.ReadyState<READYSTATE_COMPLETE do
      Application.ProcessMessages;
  finally
    stringlist.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  document: IHTMLDocument2;
  forms: IHTMLFormElement;
  element: IHTMLElement;
  i: Integer;
  inputelement: IHTMLInputElement;
  s: String;
begin
  document:=WebBrowser.Document as IHTMLDocument2;
  forms:=document.forms.item('test', 0) as IHTMLFormElement;
  s:='';
  for i:=0 to forms.length-1 do
  begin
    element:=forms.item(i, '') as IHTMLElement;
    if element.tagName='INPUT' then
    begin
      inputelement:=element as IHTMLInputElement;
      if inputelement.type_='radio' then
      begin
        s:=s+inputelement.value+' ';
        if inputelement.checked then s:=s+'is checked'+#13#10
        else s:=s+''+#13#10;
      end;
    end;
  end;
  ShowMessage(s);
end;

end.

http://data.cod.ru/78789
ссылка жива 3 дня!!!
__________________
Пишу программы за еду.
__________________
Ответить с цитированием