Delphi - WebBrowser가 사용자 정의 HTML 내용을 로드하고 표시

1448 단어 htmlDelphiidhttp
use  
  Winapi.ActiveX;   //  IPersistStreamInit 

procedure TForm1.Button2Click(Sender: TObject);  
var  
  PostList: TStringList;  
  Response, StrStream: TStringStream;  
  ResultString: string;  
begin  
  //     
  PostList := TStringList.Create;  
  Response := TStringStream.Create('', TEncoding.UTF8);  
  try  
    IdHTTP1.HandleRedirects := True;  
  
    PostList.Add('forward=');  
    PostList.Add('jumpurl=http://www.hualongxiang.com/index.php');  
    PostList.Add('step=2');  
    PostList.Add('pwuser=' + Trim(Edit1.Text));  
    PostList.Add('lgt=0');  
    PostList.Add('pwpwd=' + Trim(Edit2.Text));  
    PostList.Add('cktime=31536000');  
  
    ResultString := IdHTTP1.Post('http://jia.hualongxiang.com/register.php', PostList);  
  
    if Pos('200 OK', IdHTTP1.ResponseText) > 0 then  
    begin  
      	Memo1.Lines.Add(ResultString);  
   	//      WebBrowser     HTML    
        WebBrowser1.Navigate('about:blank'); //     
        StrStream := TStringStream.Create(ResultString);  
        try  
          StrStream.Position:=0;  
          (WebBrowser1.Document as IPersistStreamInit).Load(TStreamadapter.Create(StrStream)); //       
        finally  
          StrStream.Free;  
        end;  
    	//       
    end;  
  
  finally  
    PostList.Free;  
    Response.Free;  
  end;  
end;

좋은 웹페이지 즐겨찾기