RichEdit控件加载背景图片
2012-01-06 23:19
288 查看
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, jpeg;
type
TForm1 = class(TForm)
Image1: TImage;
RichEdit1: TRichEdit;
procedure ClassWndProc(var Msg: TMessage);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
///////////////几个重要参数///////////
wproc: pointer;
oldproc: TWndMethod;
bb: hBrush;
implementation
{$R *.dfm}
procedure Tform1.ClassWndProc(var Msg: TMessage);
begin
if msg.Msg = WM_ERASEBKGND then
msg.result:=1
else if (msg.Msg=CN_CTLCOLORMSGBOX) or (msg.Msg=CN_CTLCOLORSTATIC) then
begin
bb:=null;
msg.result := bb
end
else
oldproc(msg)
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
oldproc:=RichEdit1.WindowProc;
RichEdit1.WindowProc := form1.ClassWndProc;
SetWindowLong(RichEdit1.Handle, GWL_EXSTYLE, GetWindowLong(RichEdit1.Handle,GWL_EXSTYLE) or WS_EX_TRANSPARENT);
end;
end.
说明:
1. 使RichEdit的窗口透明. SetWindowLong(RichEdit.Handle, GWL_EXSTYLE, GetWindowLong(RichEdit.Handle,GWL_EXSTYLE) or WS_EX_TRANSPARENT);
2. 截获RichEdit的Wndproc, 处理以下消息:
CN_CTLCOLORMSGBOX..CN_CTLCOLORSTATIC: 返回一个NullBrush的handle
(防止编辑状态时
清除背景).
WM_ERASEBKGND: 什么都不做就返回1(防止窗口在刷新时清除背景)
相关文章推荐
- RichEdit控件加载背景图片
- MFC 对话框载入背景图片-控件加载图片
- VC对话框加载图片、改变背景颜色、画图、显示隐藏控件
- 给对话框加载图片背景,使得窗口大小改变时,控件还在
- IOS开发之控件加载背景图片
- MDI主框架加载背景图片
- MFC 加入背景图片并让控件背景透明
- 笔记-CSS空背景图片会导致页面被加载两次
- MFC PICTURE控件加载JPG图片
- WPF 后台C#设置控件背景图片
- Android 图片控件Fresco加载网络图片
- MFC CStatic控件插入背景图片
- QT中几种设置控件的图片背景的方法
- Glide 加载图片背景变绿
- C# WPF按钮控件动态加载图片
- MFC picture控件加载透明png图片
- Bitmap的二次采样,异步加载网络图片到控件上
- QT中几种设置控件的图片背景的方法
- 图片预加载、占位背景图jquery plugin
- Swinghacks——给文本控件添加图片背景