- // 設置窗體的透明度iTransparetn爲0~255
- void Transparent(HWND hwnd, int iTransparent)
- {
- HINSTANCE hInstance = LoadLibrary("User32.dll");
- // 設置窗體的擴展樣式
- SetWindowLong(hwnd, GWL_EXSTYLE, 0x80000);
- if (hInstance)
- {
- typedef BOOL (WINAPI *SLWA)(HWND, COLORREF, BYTE, DWORD);
- SLWA pFun = NULL;
- // 獲取函數的地址
- pFun = (SLWA)GetProcAddress(hInstance, "SetLayeredWindowAttributes");
- if (pFun)
- {
- pFun(hwnd, 0, iTransparent, 2);
- }
- }
- // 釋放實例句柄
- FreeLibrary(hInstance);
- }