myWinAttrib.cpp
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:1k
- #include "stdafx.h"
- #include "windows.h"
- #include "myWinAttrib.h"
- //判断系统是否NT
- BOOL myWinAttrib:: MyIsWinNT()
- {
- BOOL ret ;
- OSVERSIONINFO osvi;
- osvi.dwOSVersionInfoSize = 148;
- GetVersionEx(&osvi);
- if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
- ret= 1;
- else
- ret= 0;
- return ret;
- }
- myWinAttrib::myWinAttrib()
- {
- hUser32 = GetModuleHandle("user32.dll");
- isset=1;
- SetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32,"SetLayeredWindowAttributes");
- }
- myWinAttrib::~myWinAttrib()
- {
- FreeLibrary(hUser32);//卸载TranChiDll.dll文件;
- }
- int myWinAttrib::mySetWindow(HWND hWnd, long crKey, BYTE bAlpha, DWORD dwFlags)
- {
- if(isset==1 && MyIsWinNT())
- {
- SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE)|WS_EX_LAYERED);
- //SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_LAYERED);
- //LWA_ALPHA|LWA_COLORKEY可以使两种特殊效果同时生效,
- SetLayeredWindowAttributes(hWnd, crKey , bAlpha, dwFlags);
- isset=1;
- }
- return 0;
- }