Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.7 KiB

  1. // SAFChannelNotifyIncident.cpp : Implementation of CSAFChannelNotifyIncident
  2. #include "stdafx.h"
  3. #include "obj\i386\SAFInciTrac.h"
  4. #include "SAFChannelNotifyIncident.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CSAFChannelNotifyIncident
  7. UINT CSAFChannelNotifyIncident::m_nRefCount = 0;
  8. CSAFInciTrayIcon CSAFChannelNotifyIncident::m_TrayIcon(CSAFChannelNotifyIncident::m_nRefCount);
  9. STDMETHODIMP CSAFChannelNotifyIncident::onIncidentAdded(ISAFChannel *ch, ISAFIncidentItem *inc, long n)
  10. {
  11. ::MessageBox(NULL,L"In Added",NULL,MB_OK);
  12. m_nRefCount++;
  13. if (CSAFInciTrayIcon::dwThreadId == 0)
  14. {
  15. HANDLE hnd = CreateThread(NULL,0,CSAFInciTrayIcon::SAFInciTrayIconThreadFn,&m_TrayIcon,0,&CSAFInciTrayIcon::dwThreadId);
  16. if (hnd)
  17. CloseHandle(hnd);
  18. }
  19. else
  20. {
  21. m_TrayIcon.ChangeToolTip();
  22. }
  23. return S_OK;
  24. }
  25. STDMETHODIMP CSAFChannelNotifyIncident::onIncidentRemoved(ISAFChannel *ch, ISAFIncidentItem *inc, long n)
  26. {
  27. ::MessageBox(NULL,L"In Remove",NULL,MB_OK);
  28. if (m_nRefCount)
  29. {
  30. m_nRefCount--;
  31. m_TrayIcon.ChangeToolTip();
  32. if (m_nRefCount == 0)
  33. {
  34. m_TrayIcon.RemoveTrayIcon();
  35. if (!PostThreadMessage(CSAFInciTrayIcon::dwThreadId,WM_QUIT,0,0))
  36. {
  37. DWORD dwError = GetLastError();
  38. TCHAR strBuf[100];
  39. wsprintf(strBuf,_T("The error is %d"),dwError);
  40. ::MessageBox(NULL,strBuf,NULL,MB_OK);
  41. }
  42. CSAFInciTrayIcon::dwThreadId = 0;
  43. }
  44. }
  45. return S_OK;
  46. }
  47. STDMETHODIMP CSAFChannelNotifyIncident::onIncidentUpdated(ISAFChannel *ch, ISAFIncidentItem *inc, long n)
  48. {
  49. m_TrayIcon.m_wIconId = IDI_ALERTINCIDENT;
  50. m_TrayIcon.ModifyIcon();
  51. return S_OK;
  52. }
  53. STDMETHODIMP CSAFChannelNotifyIncident::onChannelUpdated(ISAFChannel *ch, long dwCode, long n)
  54. {
  55. // m_TrayIcon.ChangeIcon(IDI_NORMALINCIDENT);
  56. return S_OK;
  57. }