窗口透明的问题

Bob2000 2002-11-22 09:17:26
当调用SetLayeredWindowAttributes函数时,错误提示如下:
error C2065: 'SetLayeredWindowAttributes' : undeclared identifier

程序中已经包含
#include <Winuser.h>
#include <Windows.h>
的声明。

#define LWA_ALPHA 0x00000002
SetLayeredWindowAttributes(hwnd,RGB(0,0,0),100,LWA_ALPHA);

系统是Win2000,所以是支持此函数的。不知道是不是还需要设定什么条件?

...全文
104 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingcom_xu 2002-11-22
  • 打赏
  • 举报
回复
按照你上面的错误提示。。。应该不是我贴的程序产生的问题。。。
Bob2000 2002-11-22
  • 打赏
  • 举报
回复
用你贴的第二种方法,编译还有错误提示:
SetTransPlusDlg.obj : error LNK2001: unresolved external symbol __imp__SetLayeredWindowAttributes@16
Release/SetTransPlus.exe : fatal error LNK1120: 1 unresolved externals

是不是一定要装最新的SDK啊?
kingcom_xu 2002-11-22
  • 打赏
  • 举报
回复
http://download.microsoft.com/download/platformsdk/sdk/update
Bob2000 2002-11-22
  • 打赏
  • 举报
回复
能否给个微软网站最新SDK的下载链接,非常感谢,分一会送上。
kingcom_xu 2002-11-22
  • 打赏
  • 举报
回复
否则:

#ifndef WS_EX_LAYERED
#define WS_EX_LAYERED 0x00080000
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
#endif // ndef WS_EX_LAYERED


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

lpfnSetLayeredWindowAttributes m_pSetLayeredWindowAttributes;



HMODULE hUser32 = GetModuleHandle("USER32.DLL");
m_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes");

if (NULL == m_pSetLayeredWindowAttributes)
return FALSE;

SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
m_pSetLayeredWindowAttributes(hWnd, 0, 200, LWA_ALPHA);
kingcom_xu 2002-11-22
  • 打赏
  • 举报
回复
如果你下载了最新的SDK的话。。。请在stdafx.h中加入:

#ifndef WINVER // 允许使用 Windows 95 和 Windows NT 4 或更高版本的特定功能。
#define WINVER 0x0501 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
#endif

#ifndef _WIN32_WINNT // 允许使用 Windows NT 4 或更高版本的特定功能。
#define _WIN32_WINNT 0x0501 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
#endif

#ifndef _WIN32_IE // 允许使用 IE 4.0 或更高版本的特定功能。
#define _WIN32_IE 0x0600 //为 IE 5.0 及更新版本改变为适当的值。
#endif

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧