RichEdit控件加载背景图片
2009-10-06 16:28
302 查看
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控件加载背景图片
- IOS开发之控件加载背景图片
- MFC 对话框载入背景图片-控件加载图片
- VC对话框加载图片、改变背景颜色、画图、显示隐藏控件
- 给对话框加载图片背景,使得窗口大小改变时,控件还在
- [Android开发] 代码code设置9.png/9-patch 图片背景后,此view中的TextView等控件显示不正常(常见于listview中)
- VC++工作第一天Dialog对话框加载静态背景图片之一BITMAP。
- 笔记-CSS空背景图片会导致页面被加载两次
- 快速开发框架Afinal的使用(数据库操作,HTTP请求,网络图片加载,控件绑定)
- ios控件加载图片,plist,懒加载,序列帧动画,添加动画效果。
- QWebView中出现加载网页乱码、图片加载不出来的问题解决以级QMainWindow背景图片设置问题
- C#发现之旅 --- WinForm.NET中开发具有固定背景图片的可滚动控件
- PictureControl控件加载图片
- 代码code设置9.png/9-patch 图片背景后,此view中的TextView等控件显示不正常(常见于listview中)
- VC 给对话框加载背景图片示例
- Qt利用setstylesheet给控件设置背景图片不能显示
- MFC中CImage加载png图片出现黑色背景的解决办法!
- Android使用控件ImageView加载图片的方法
- MFC工程更改按钮背景颜色,编辑框背景颜色,给按钮加载图片
- 网络图片设置为控件背景图