// Set WS_EX_LAYERED on this window SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); // Make this window 70% alpha SetLayeredWindowAttributes(hWnd, 0, (255*70) /100, LWA_ALPHA);
至少需要Windows 2000系统来运行程序,编译的时候也需要Platform SDK支持。
PlatformSDK安装完之后,需要在VC环境中设置include/lib的路径,把新的SDK路径放在搜索的最前面,保证编译器首先找到的文件是新版本的。
微软网站上提供的最新版本SDK安装完成后,可以在开始菜单中找到“Visual Studio Registration”,自动帮你完成添加include/lib路径的工作。
窗口Create后添加下面代码就可以实现半透明效果。 // Set WS_EX_LAYERED on this window SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); // Make this window 70% alph