MFC设置透明窗口

void SetLayeredWindow(HWND m_hWnd,int nRate)
{
  HINSTANCE hInst;
  if ((hInst = LoadLibrary(_T("USER32.dll"))) != NULL)
    {

        SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) | 
   WS_EX_LAYERED);

  typedef BOOL (WINAPI* lpfnSetTransparent)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);


if (hInst)
{
lpfnSetTransparent pFnSetTransparent = NULL;
pFnSetTransparent= (lpfnSetTransparent)GetProcAddress(hInst, "SetLayeredWindowAttributes");
if (pFnSetTransparent)
pFnSetTransparent(m_hWnd, 0, (255 * nRate) / 100, LWA_ALPHA);
}
    }

}

 

展开阅读全文

没有更多推荐了,返回首页