Framework 1.0/1.1中NotifyIcon的不足
.NET Framework 1.0/1.1中给我们提供了一个NotifyIcon类,使用这个类我们可以非常方便的实现系统托盘(SystemTray)图标。可是不知道微软是为了兼容性还是为了偷懒,只实现了NOTIFYICONDATA结构的v5.0之前版本,也就是说不支持5.0及以后的balloon tip功能。
Shell struct v5.0 and later中的NOTIFYICONDATA结构定义为:
而微软Framework 1.0/1.1中实现的NOTIFYICONDATA是:
不过稍微感到欣慰的是在Framework 2.0中,NotifyIcon支持了v5.0以后的Balloon Tip功能。
Shell struct v5.0 and later中的NOTIFYICONDATA结构定义为:
typedef struct _NOTIFYICONDATA {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
TCHAR szTip[64];
DWORD dwState;
DWORD dwStateMask;
TCHAR szInfo[256];
union {
UINT uTimeout;
UINT uVersion;
};
TCHAR szInfoTitle[64];
DWORD dwInfoFlags;
GUID guidItem;
} NOTIFYICONDATA, *PNOTIFYICONDATA;
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
TCHAR szTip[64];
DWORD dwState;
DWORD dwStateMask;
TCHAR szInfo[256];
union {
UINT uTimeout;
UINT uVersion;
};
TCHAR szInfoTitle[64];
DWORD dwInfoFlags;
GUID guidItem;
} NOTIFYICONDATA, *PNOTIFYICONDATA;
而微软Framework 1.0/1.1中实现的NOTIFYICONDATA是:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto, Pack=1)]
public class NOTIFYICONDATA
{
public int cbSize;
public IntPtr hWnd;
public int uID;
public int uFlags;
public int uCallbackMessage;
public IntPtr hIcon;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=0x40)]
public string szTip;
public NOTIFYICONDATA()
{
this.cbSize = Marshal.SizeOf(typeof(NativeMethods.NOTIFYICONDATA));
}
}
public class NOTIFYICONDATA
{
public int cbSize;
public IntPtr hWnd;
public int uID;
public int uFlags;
public int uCallbackMessage;
public IntPtr hIcon;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=0x40)]
public string szTip;
public NOTIFYICONDATA()
{
this.cbSize = Marshal.SizeOf(typeof(NativeMethods.NOTIFYICONDATA));
}
}
不过稍微感到欣慰的是在Framework 2.0中,NotifyIcon支持了v5.0以后的Balloon Tip功能。
posted on 2005-05-17 16:50 birdshome 阅读(1678) 评论(3) 编辑 收藏 举报