程序 托盘区 VC6.0 编译 弹出气球 出现错误 error C2065解决办法

2011-11-1 王健宇 转载

今天在编译一份mentohust的源代码出现了错误,所以上网查了一下解决方法。现在转载。

 

用VC6.0制作对话框程序,想用 弹出气球 提示时,编译总出现以下错误:

error C2065: 'NIIF_INFO' : undeclared identifier
D:\login\loginDlg.cpp(918) : error C2065: 'NIF_INFO' : undeclared identifier
D:\login\loginDlg.cpp(918) : error C2065: 'NIIF_ERROR' : undeclared identifier
D:\login\loginDlg.cpp(919) : error C2039: 'uTimeout' : is not a member of '_NOTIFYICONDATAA'
d:\program files\microsoft visual studio\vc98\include\shellapi.h(500) : see declaration of '_NOTIFYICONDATAA'
D:\login\loginDlg.cpp(920) : error C2039: 'dwInfoFlags' : is not a member of '_NOTIFYICONDATAA'
d:\program files\microsoft visual studio\vc98\include\shellapi.h(500) : see declaration of '_NOTIFYICONDATAA'
D:\login\loginDlg.cpp(921) : error C2039: 'szInfo' : is not a member of '_NOTIFYICONDATAA'
d:\program files\microsoft visual studio\vc98\include\shellapi.h(500) : see declaration of '_NOTIFYICONDATAA'
D:\login\loginDlg.cpp(922) : error C2039: 'szInfoTitle' : is not a member of '_NOTIFYICONDATAA'
d:\program files\microsoft visual studio\vc98\include\shellapi.h(500) : see declaration of '_NOTIFYICONDATAA'
MD5.cpp
setDlg.cpp
Generating Code...
Error executing cl.exe.

login.exe - 7 error(s), 0 warning(s)

这个问题主要是由于SHELLAPI.H比较旧了,我们需要更改一下这个文件。找到VC++6.0的安装目录,我的是装在了D盘,即:"D:\Program Files\Microsoft Visual Studio\VC98\include\,到这个目录下后,你可以发现许多.h文件。找到SHELLAPI.H,然后用记事本打开,用查找命令,找到“//// Tray notification definitions”这一行,大概在记事本第504行。然后再找到“//// End Tray Notification Icons”这一行,把这两行之间的内容全部注释掉或者删除,包括那两行,再重新粘贴上这些内容:

//// Tray notification definitions
////

typedef struct _NOTIFYICONDATAA {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
#if (_WIN32_IE < 0x0500)
CHAR szTip[64];
#else
CHAR szTip[128];
#endif
#if (_WIN32_IE >= 0x0500)
DWORD dwState;
DWORD dwStateMask;
CHAR szInfo[256];
union {
UINT uTimeout;
UINT uVersion;
} DUMMYUNIONNAME;
CHAR szInfoTitle[64];
DWORD dwInfoFlags;
#endif
#if (_WIN32_IE >= 0x600)
GUID guidItem;
#endif
} NOTIFYICONDATAA, *PNOTIFYICONDATAA;
typedef struct _NOTIFYICONDATAW {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
#if (_WIN32_IE < 0x0500)
WCHAR szTip[64];
#else
WCHAR szTip[128];
#endif
#if (_WIN32_IE >= 0x0500)
DWORD dwState;
DWORD dwStateMask;
WCHAR szInfo[256];
union {
UINT uTimeout;
UINT uVersion;
} DUMMYUNIONNAME;
WCHAR szInfoTitle[64];
DWORD dwInfoFlags;
#endif
#if (_WIN32_IE >= 0x600)
GUID guidItem;
#endif
} NOTIFYICONDATAW, *PNOTIFYICONDATAW;
#ifdef UNICODE
typedef NOTIFYICONDATAW NOTIFYICONDATA;
typedef PNOTIFYICONDATAW PNOTIFYICONDATA;
#else
typedef NOTIFYICONDATAA NOTIFYICONDATA;
typedef PNOTIFYICONDATAA PNOTIFYICONDATA;
#endif // UNICODE


#define NOTIFYICONDATAA_V1_SIZE FIELD_OFFSET(NOTIFYICONDATAA, szTip[64])
#define NOTIFYICONDATAW_V1_SIZE FIELD_OFFSET(NOTIFYICONDATAW, szTip[64])
#ifdef UNICODE
#define NOTIFYICONDATA_V1_SIZE NOTIFYICONDATAW_V1_SIZE
#else
#define NOTIFYICONDATA_V1_SIZE NOTIFYICONDATAA_V1_SIZE
#endif

#define NOTIFYICONDATAA_V2_SIZE FIELD_OFFSET(NOTIFYICONDATAA, guidItem)
#define NOTIFYICONDATAW_V2_SIZE FIELD_OFFSET(NOTIFYICONDATAW, guidItem)
#ifdef UNICODE
#define NOTIFYICONDATA_V2_SIZE NOTIFYICONDATAW_V2_SIZE
#else
#define NOTIFYICONDATA_V2_SIZE NOTIFYICONDATAA_V2_SIZE
#endif


#if (_WIN32_IE >= 0x0500)
#define NIN_SELECT (WM_USER + 0)
#define NINF_KEY 0x1
#define NIN_KEYSELECT (NIN_SELECT | NINF_KEY)
#endif

#if (_WIN32_IE >= 0x0501)
#define NIN_BALLOONSHOW (WM_USER + 2)
#define NIN_BALLOONHIDE (WM_USER + 3)
#define NIN_BALLOONTIMEOUT (WM_USER + 4)
#define NIN_BALLOONUSERCLICK (WM_USER + 5)
#endif


#define NIM_ADD 0x00000000
#define NIM_MODIFY 0x00000001
#define NIM_DELETE 0x00000002
#if (_WIN32_IE >= 0x0500)
#define NIM_SETFOCUS 0x00000003
#define NIM_SETVERSION 0x00000004
#define NOTIFYICON_VERSION 3
#endif

#define NIF_MESSAGE 0x00000001
#define NIF_ICON 0x00000002
#define NIF_TIP 0x00000004
#if (_WIN32_IE >= 0x0500)
#define NIF_STATE 0x00000008
#define NIF_INFO 0x00000010
#endif
#if (_WIN32_IE >= 0x600)
#define NIF_GUID 0x00000020
#endif

#if (_WIN32_IE >= 0x0500)
#define NIS_HIDDEN 0x00000001
#define NIS_SHAREDICON 0x00000002

// says this is the source of a shared icon

// Notify Icon Infotip flags
#define NIIF_NONE 0x00000000
// icon flags are mutually exclusive
// and take only the lowest 2 bits
#define NIIF_INFO 0x00000001
#define NIIF_WARNING 0x00000002
#define NIIF_ERROR 0x00000003
#define NIIF_ICON_MASK 0x0000000F
#if (_WIN32_IE >= 0x0501)
#define NIIF_NOSOUND 0x00000010
#endif
#endif

SHSTDAPI_(BOOL) Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA lpData);
SHSTDAPI_(BOOL) Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW lpData);
#ifdef UNICODE
#define Shell_NotifyIcon Shell_NotifyIconW
#else
#define Shell_NotifyIcon Shell_NotifyIconA
#endif // !UNICODE

////
//// End Tray Notification Icons
////

关闭VC,重新打开后再编译试试。

如果问题仍然存在,可以选择组建->全部组建。

标签: SHELLAPI.H VC6.0弹出气球出现错误 errorC2065解决办法

发表评论:

Powered by emlog sitemap