IT/MFC

[팁] 초간단 투명윈도우..(win2k 이상)

KSI 2005. 6. 24. 05:39

////////////define

typedefBOOL (WINAPI *SetLayer)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
#defineLWA_COLORKEY            0x01
#defineLWA_ALPHA               0x02

 

////////////in func.

 HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL"));
 SetLayer pSetLayer = (SetLayer)GetProcAddress(hUser32, "SetLayeredWindowAttributes");
 if(pSetLayer == NULL)
 {
  MessageBox("win2000 이상");
  return;
 }
 charchAlpha =m_slider.GetPos();//투명도 설정 0 ~ 255
 SetWindowLong(this->m_hWnd, GWL_EXSTYLE,

                           GetWindowLong(this->m_hWnd, GWL_EXSTYLE) | 0x80000);
 pSetLayer(this->m_hWnd, 0,chAlpha, LWA_ALPHA);

  

m_slider는 slider control 변수다.