1 /* 2 * Copyright 2018 Hermes Belusca-Maito 3 * 4 * Pass on icon notification messages to the systray implementation 5 * in the currently running shell. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef _USERNOTIFICATION_H_ 23 #define _USERNOTIFICATION_H_ 24 25 #undef PlaySound 26 27 class CUserNotification : 28 public CComCoClass<CUserNotification, &CLSID_UserNotification>, 29 public CComObjectRootEx<CComMultiThreadModelNoCS>, 30 public IUserNotification 31 // public IUserNotification2 // On Vista+ 32 { 33 private: 34 HWND m_hWorkerWnd; 35 HICON m_hIcon; 36 DWORD m_dwInfoFlags; 37 UINT m_uShowTime; 38 UINT m_uInterval; 39 UINT m_cRetryCount; 40 UINT m_uContinuePoolInterval; 41 BOOL m_bIsShown; 42 HRESULT m_hRes; 43 IQueryContinue* m_pqc; 44 CStringW m_szTip; 45 CStringW m_szInfo; 46 CStringW m_szInfoTitle; 47 48 private: 49 VOID RemoveIcon(); 50 VOID DelayRemoveIcon(IN HRESULT hRes); 51 VOID TimeoutIcon(); 52 53 VOID SetUpNotifyData( 54 IN UINT uFlags, 55 IN OUT PNOTIFYICONDATAW pnid); 56 57 static LRESULT CALLBACK 58 WorkerWndProc( 59 IN HWND hWnd, 60 IN UINT uMsg, 61 IN WPARAM wParam, 62 IN LPARAM lParam); 63 64 public: 65 CUserNotification(); 66 ~CUserNotification(); 67 68 // IUserNotification 69 STDMETHOD(SetBalloonInfo)( 70 IN LPCWSTR pszTitle, 71 IN LPCWSTR pszText, 72 IN DWORD dwInfoFlags) override; 73 74 STDMETHOD(SetBalloonRetry)( 75 IN DWORD dwShowTime, // Time intervals in milliseconds 76 IN DWORD dwInterval, 77 IN UINT cRetryCount) override; 78 79 STDMETHOD(SetIconInfo)( 80 IN HICON hIcon, 81 IN LPCWSTR pszToolTip) override; 82 83 // Blocks until the notification times out. 84 STDMETHOD(Show)( 85 IN IQueryContinue* pqc, 86 IN DWORD dwContinuePollInterval) override; 87 88 STDMETHOD(PlaySound)( 89 IN LPCWSTR pszSoundName) override; 90 91 #if 0 92 // IUserNotification2 93 // Blocks until the notification times out. 94 STDMETHOD(Show)( 95 IN IQueryContinue* pqc, 96 IN DWORD dwContinuePollInterval, 97 IN IUserNotificationCallback* pSink) override; 98 #endif 99 100 DECLARE_REGISTRY_RESOURCEID(IDR_USERNOTIFICATION) 101 DECLARE_NOT_AGGREGATABLE(CUserNotification) 102 103 DECLARE_PROTECT_FINAL_CONSTRUCT() 104 105 BEGIN_COM_MAP(CUserNotification) 106 COM_INTERFACE_ENTRY_IID(IID_IUserNotification , IUserNotification ) 107 // COM_INTERFACE_ENTRY_IID(IID_IUserNotification2, IUserNotification2) 108 END_COM_MAP() 109 }; 110 111 #endif /* _USERNOTIFICATION_H_ */ 112