Delphi在Webbrowser上绘制图像

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, OleCtrls, IEBrowser;

type
  TForm1 = class(TForm)
    Button1: TButton;
    CppWebBrowser1: TCppWebBrowser;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    OldMessage: TWndMethod;
    procedure OleMessage(var Msg: TMessage);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  CppWebBrowser1.Navigate('www.baidu.com');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  //WebBrowser1.Navigate('www.baidu.com');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  OldMessage := CppWebBrowser1.WindowProc;
  CppWebBrowser1.WindowProc := OleMessage;
end;

procedure TForm1.OleMessage(var Msg: TMessage);
var
  c: TCanvas;
  bmpBG: TBitmap;
begin
  OldMessage(Msg);
  if Msg.Msg=WM_PAINT then
  begin
    bmpBG := TBitmap.Create;
    bmpBG.Transparent := true;
    bmpBG.LoadFromFile(ExtractFilePath(Application.ExeName) + 'back.bmp');
    c := TControlCanvas.Create;
    TControlCanvas(c).Control := CppWebBrowser1;
    c.Brush.Style := bsClear;
    c.StretchDraw(c.ClipRect, bmpBG);
  end;
end;

end.


上一篇: AdminCMD
下一篇: 这是最新的一篇日志
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: Delphi Webbrowser 图像 TCanvas TBitmap
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭