Search code examples
notificationstooltiptrayiconpopup-balloonsballoon-tip

How to Handle The Notification (Shell_NotifyIcon) to perform Some action when user clicked on It?


Iam NewBie, I have Created Tray Icon for my Application with

 void createTrayIcon(LpSTR msg)
 {
  memset(&m_NID, 0 , sizeof(m_NID));

m_NID.cbSize = sizeof(m_NID);

// set tray icon ID
m_NID.uID = ID_SYSTEMTRAY  ;


// set handle to the window that receives tray icon notifications
ASSERT(::IsWindow(GetSafeHwnd()));
m_NID.hWnd = GetSafeHwnd();

// set message that will be sent from tray icon to the window  
m_NID.uCallbackMessage = WM_TRAYICON_EVENT;

StringCchCopy(m_NID.szInfo, ARRAYSIZE(m_NID.szTip),msg);
StringCchCopy(m_NID.szInfoTitle, ARRAYSIZE(m_NID.szInfoTitle), L"DuOS");

// fields that are being set when adding tray icon
m_NID.uFlags = NIF_MESSAGE|NIF_ICON|NIF_INFO;   

// set image
m_NID.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

if(!m_NID.hIcon)
    return FALSE;

return Shell_NotifyIcon(NIM_ADD, &m_NID);

}

I Am Showing the Notifications By Using

Shell_NotifyIcon(NIM_MODIFY , &m_NID);
My problem is I want to handle that Notification i.e, If user clicks on that
Notification I need to do some action, How to achieve this

I am trying for this from last two days I had Googled Lot of times and searched lot of blogs But I cant, Anyone Please Help me Out


Solution

  • Finally I Got the Answer ,

    there was a NIN_BALOONUSERCLICK flag was there, if User clicks on Baloon it will return this Flag...