重载RichEdit的WndProc改写WM_ERASEBKGND、CN_CTLCOLORMSGBOX、CN_CTLCOLORSTATIC消息 代码如下: 在Form类中声明 Graphics::TBitmap *bmp;TWndMethod OldProc;void __fastcall NewProc(TMessage message){ if(message.Msg== WM_ERASEBKGN
重载RichEdit的WndProc改写WM_ERASEBKGND、CN_CTLCOLORMSGBOX、CN_CTLCOLORSTATIC消息
代码如下:
在Form类中声明
Graphics::TBitmap *bmp;
TWndMethod OldProc;
void __fastcall NewProc(TMessage &message)
{
if(message.Msg== WM_ERASEBKGND)
message.Result=1;
else if((message.Msg==CN_CTLCOLORMSGBOX)||(message.Msg==CN_CTLCOLORSTATIC)
)
{
message.Result=NULL_BRUSH;
}
else
OldProc(message);}
在Form构造函数中
替换RichEdit窗口过程,设置扩展透明样式
bmp=new Graphics::TBitmap;
bmp->LoadFromFile("a.bmp");
OldProc=RichEdit1->WindowProc;
RichEdit1->WindowProc=NewProc; SetWindowLong(RichEdit1->Handle, GWL_EXSTYLE, GetWindowLong(RichEdit1->Handle,GWL_EXSTYLE) | WS_EX_TRANSPARENT);
OK,最后在Form的OnPaint中处理背景图片
Canvas->Draw(0,0,bmp);
【感谢龙石为本站提供信息共享平台 http://www.longshidata.com/pages/exchange.html】