把鼠标移动到系统托盘图标上时,显示提示信息。我使用下面代码实现,可是鼠标放上去后,提示信息并没有出来。
BOOL CMKNKDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
m_cTrayIcon.TrayIconAdd( m_hWnd,
ID_TRAY,
TRAY_NOTIFYICON,
LoadIcon( AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_MKNK) ),
AfxGetInstanceHandle(),
IDS_TIP,
NULL );
return TRUE; // return TRUE unless you set the focus to a control
}
void CTrayIcon::TrayIconAdd( HWND hwnd,
UINT uID,
UINT uCallbackMessage,
HICON hIcon,
HINSTANCE hInstance,
UINT uTipID,
PTSTR pszTip )
{
TrayMessage(hwnd, NIM_ADD, uID, uCallbackMessage, hIcon, hInstance, uTipID, NULL);
}
BOOL CTrayIcon::TrayMessage( HWND hwnd,
DWORD dwMessage,
UINT uID,
UINT uCallbackMessage,
HICON hIcon,
HINSTANCE hInstance,
UINT uTipID,
PTSTR pszTip )
{
BOOL res = FALSE;
NOTIFYICONDATA tnd;
tnd.cbSize = sizeof(NOTIFYICONDATA);
tnd.hWnd = hwnd;
tnd.uID = uID;
tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
tnd.uCallbackMessage = uCallbackMessage;
tnd.hIcon = hIcon;
// tnd.szTip[0] = '\0';
if ( dwMessage==NIM_ADD )
LoadString( hInstance, uTipID, tnd.szTip, sizeof(tnd.szTip) );
res = Shell_NotifyIcon(dwMessage, &tnd);
return res;
}
但是鼠标放上去之后,图标并没有出现,不知道咋回事。