TEmbeddedwb的一个小bug

    这几天不知道是不是人品出了问题,老是遇上一些小bug。
    昨天在公司里写了一个有浏览网页代码的小程序,图方便,使用的是TEmbeddedwb控件,这个控件在delphi自带的TWebBrowser控件上又提供了一些选项和方法。
    拿回家以后打开这个工程,在打开浏览页面窗口的时候却出错了:“Error Creating Form:'' is not a valid floating point value”。这个窗口上没有其他控件,就只有TEmbeddedWB控件,看情况应该是打开窗口时装载该控件时出的错,而错误应该是发生在作字符转换到float型时出现的。
    新建一个工程,放上一个TEmbeddedWB控件,灭有问题啊。关掉后再打开,问题重现了。
    打开EmbeddedWB.pas单元,首先查找StrToFloat函数,呵,还好,只有两个地方用到,一看都是在GetPrintValues函数用的,函数内容如下:
procedure TembeddedWB.GetPrintValues;
var
  S: string;
  regWinRegistry: TRegistry;

  function ReadMargin(key: string): Real;
  begin
    S := RegwinRegistry.ReadString(key);
    S := Stringreplace(S, ' ', '', [rfReplaceAll]);
    if DecimalSeparator <> '.' then
      S := Stringreplace(S, '.', DecimalSeparator, []);
    if Printoptions.Measure = mMetric then
      result := StrtoFloat(S) * InchToMetric else
      result := StrtoFloat(S);
  end;

begin
  regWinRegistry := TRegistry.Create;
  try
    with regWinRegistry do begin
      RootKey := HKEY_CURRENT_USER;
      if OpenKey('Software/Microsoft/Internet Explorer/PageSetup', False) then
      begin
        PrintOptions.Header := Readstring('header');
        PrintOptions.Footer := ReadString('footer');
        PrintOptions.Margins.left := ReadMargin('margin_left');
        PrintOptions.Margins.right := ReadMargin('margin_right');
        PrintOptions.Margins.top := ReadMargin('margin_top');
        PrintOptions.Margins.bottom := ReadMargin('margin_bottom');
      end;
    end;
  finally
    regWinRegistry.Free;
  end;
end;

    这个函数是在注册表中去取IE的打印设置,打开注册表一看,果然没有'margin_left'这四个项,加上这四个字符串值,并赋上初值0。打开窗口。OK。高兴之余也不禁感慨,这个xp的操作系统装上以后还灭怎么摧残过,照理这四个键不是偶搞掉的,也就说系统装上就没有的,到底是microsoft人品有问题还是偶人品有问题已经不重要了,可是偶现在才明白,原来大师的程序也有bug啊,为什么不用StrToFloatDef函数哩?
    今天在公司机器上一看,果然有这四个键,每个值为0.75。

    小bug一个,仅作记录,以供有同样情形的同志参考。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Delphi第三方控件EmbeddedWB,这是一个不错的浏览器控件,比Delphi自带的Webbrowser要强悍 EmbeddedWB安装方法: 1.下载压缩包,飘易下载的是EmbeddedWB v14.67.0版本,下载地址:http://www.delphifans.com/SoftView/SoftView_2705.html。 2.解压整个压缩包到 lib\EmbeddedWB 下; 3.复制 lib\EmbeddedWB 下的Packages目录中的EmbeddedWebBrowser_D2007.dpk(因为飘易使用的是DELPHI2007)到Source目录里; 4.用Delphi7开发环境打开 EmbeddedWebBrowser_D2007.dpk 文件,按Optios按钮,作如下调整: Directories/Conditionals标签Unit Output Dir=“D:\Program Files\CodeGear\RAD Studio\5.0\lib\EmbeddedWB\Source”(具体路径自行决定); 5.按Compile 再按Install; 6.不要保存变化了的dpk文件及压缩包; 7.在具体的编译工程时,需检查该源目录(D:\Program Files\CodeGear\RAD Studio\5.0\lib\EmbeddedWB\Source)在 Delphi IDE 的 "Search Path" 路径里(Project -> Options -> irectories/Conditionals -> Search Path); 如果没有,添加这个源目录路径。否则,在使用该控件的时候,出现“File not found: 'SHDocVw_EWB.dcu'” 错误。 8.可以正常使用了。 这里还有一篇别人的“Embedded Web Browser Delphi组件的安装”,不过是把TEmbeddedWB控件安装到 Delphi7 里的。 下面是D2005 installing steps:1.After downloading Unzip the package. 2. Put the folder that contain the package in the path "..:\Borland\BDS\3.0\lib" 3. Open Delphi IDE and press in the menu bar On: File --> "Open" In the open dialog navigate to the path where you store your package to the source folder("..:\Borland\BDS\3.0\lib\EmbeddedWB_D2005\Source"). 5.Choose file name "EmbeddedWebBrowser_D2005.dpk" and press open. 6.In the project manager (in the right corner) point with your mouse on the top file ("EmbeddedWebBrowser_D2005.bdsproj"). Then Right click and choose "Build" 7. And last In the same file & menu Press install. 8. Do not save the package changes. 9. You should make sure that the source folder is in the Delphi IDE "Search Path". If not You must add it.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值