制作透明窗体
2008-03-08 21:54:12 来源:WEB开发网核心提示:1.重载CreateParams函数,设置透明风格2.然后重载它的WM_ERASEBKGND消息,制作透明窗体,代码片段:.h Fileclass TYourForm:public TForm{PRivate:void __fastcall WMNC(TMessage &Message);public:__fastca
1.重载CreateParams函数,设置透明风格
2.然后重载它的WM_ERASEBKGND消息。
代码片段:
.h File
class TYourForm:public TForm
{
PRivate:
void __fastcall WMNC(TMessage &Message);
public:
__fastcall TYourForm(TComponent *Owner);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_ERASEBKGND,TMessage,WMNC);
END_MESSAGE_MAP(TForm);
protected:
virtual void __fastcall CreateParams(TCreateParams &Params);
}
.cpp File
void __fastcall TYourForm::CreateParams(TCreateParams &Params)
{
TForm::CreateParams(Params);
Params.EX_STYLE=WS_EX_TRANSPARENT;
}
void __fastcall TYourForm::WMNC(TMessage &Message)
{
SetBkMode(GetWindowDC(this->Handle),OPAQUE);
ReleaseDC(this->Handle,GetWindowDC(this->Handle)) ;
Messgae.Result=1;
}
更多精彩
赞助商链接