建造透明窗体
当前位置:以往代写 > C/C++ 教程 >建造透明窗体
2019-06-13

建造透明窗体

建造透明窗体

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;
}

    关键字:

在线提交作业