首页 > 编程 > Java > 正文

制作透明窗体

2019-09-06 23:33:16
字体:
来源:转载
供稿:网友

                    1.重载CreateParams函数,设置透明风格
2.然后重载它的WM_ERASEBKGND消息。
代码片段:

.h File
class TYourForm:public TForm
{
private:
/tvoid __fastcall WMNC(TMessage &Message);
public:
/t__fastcall TYourForm(TComponent *Owner);
/tBEGIN_MESSAGE_MAP
/t  VCL_MESSAGE_HANDLER(WM_ERASEBKGND,TMessage,WMNC);
/tEND_MESSAGE_MAP(TForm);
protected:
/tvirtual 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;
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表