webbrowser去掉边框

  1

WebBrowser1.Width  :=  TControl(WebBrowser1).Parent.ClientWidth  +  3;  
 WebBrowser1.Height  :=  TControl(WebBrowser1).Parent.ClientHeight  +  3;  
  WebBrowser1.Left  :=  -2;  
  WebBrowser1.Top  :=  -2; 

2

procedure WB_Set3DBorderStyle(Sender: TObject; bValue: Boolean);
var
   Document : IHTMLDocument2;
   Element : IHTMLElement;
  StrBorderStyle: string;
begin
//去掉边框
try
   Document := TWebBrowser(Sender).Document as IHTMLDocument2;
  if Assigned(Document) then
begin
Element := Document.Body;
if Element <> nil then
begin
case BValue of
False: StrBorderStyle := 'none';
True: StrBorderStyle := '';
end;
Element.Style.BorderStyle := StrBorderStyle;
end;
end;
except
//..
end;
end;


procedure TFrmWebBrowser.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
WB_Set3DBorderStyle(Sender,false);
end;

你可能感兴趣的:(WebBrowser)