原文转自 http://jingyan.baidu.com/article/656db918fd5b0ee381249ca1.html

 

在OnInitDialog()函数添加以下代码:

    //设置半透明对话框
    SetWindowLong(this->GetSafeHwnd(), GWL_EXSTYLE, GetWindowLong(this->GetSafeHwnd(), GWL_EXSTYLE) ^ 0x80000);
    HINSTANCE hInst = LoadLibrary("User32.DLL");  //加载库文件
    if (hInst)
    {
        typedef BOOL(WINAPI *MYFUNC)(HWND, COLORREF, BYTE, DWORD);
        MYFUNC func = NULL; //函数指针
        //取得SetLayeredWindowAttributes函数指针 
        func = (MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
        //使用SetLayeredWindowAttributes函数设定透明度
        if (func)func(this->GetSafeHwnd(), RGB(0, 0, 0), 200, 0x2);
        FreeLibrary(hInst);
    }

 

相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2021-09-12
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
猜你喜欢
  • 2021-12-04
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案