分享

delphi WebBrowser 去边框

 sumstars 2014-11-19


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;

在对应的WebBrowser 事件中加入即可

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  W_Set3DBorderStyle(sender,false);
end;

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多