// TaskNotificationAreaItem.h // // This object manages one task notification area item. It // allows for multiple icons that can be cycled to // create animations. // // Revision Log // // Date Who SAR Notes // ========== === ======= ===================================== // 2001-10-12 mph Initial coding by Mark Henri of // MPH Software - markhenri@attbi.com // 2002-04-16 mph Complete overhaul and renaming // // // see sample code at the bottom... #ifndef TASKNOTIFICATIONAREAITEM_H #define TASKNOTIFICATIONAREAITEM_H #include #include "Icon.h" #include typedef std::vector ICONS; class CTaskNotificationAreaItem { public: CTaskNotificationAreaItem(); ~CTaskNotificationAreaItem(); BOOL LoadIcon(HINSTANCE i, int iconResId); BOOL Add(HWND hwnd, int iconNumber, LPSTR lpszTip, UINT a_uCallbackMessageValue); // adds item to the tna BOOL ChooseIcon(int iconNumber); // they're in the order loaded BOOL NextIcon(); BOOL Delete(); // removes the item from the tna protected: private: BOOL Add(HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip, UINT a_uCallbackMessageValue); BOOL ModifyIcon(HICON hicon); HWND _hwnd; ICONS _icons; }; #ifdef SAMPLE_CODE // in the includes area of the *Dlg.h file... #include "TaskNotificationAreaItem.h" // in the private area of the *Dlg.h class definition... CTaskNotificationAreaItem tnaItem; void OnTNAMessage(WPARAM wParam, LPARAM lParam); // in one of the startup routines such as OnInitialize or // a button event... tnaItem.LoadIcon(GetInstance(), IDI_MAIN); // or tnaItem.LoadIcon(GetInstance(), IDI_ANAMATION1); tnaItem.LoadIcon(GetInstance(), IDI_ANAMATION2); tnaItem.LoadIcon(GetInstance(), IDI_ANAMATION3); // in one of the closing routines such as OnCancel() or // OnClose()... tnaItem.Delete(); // Implement the following routine in your derived // dialog box. Add the message handler code void CMyDlg::OnTNAMessage(WPARAM wParam, LPARAM lParam) { UINT uID =(UINT) wParam; UINT uMouseMsg =(UINT) lParam; switch (uID) { case 1: // arbitrary number assigned to the icon for this window switch (uMouseMsg) { case WM_MOUSEMOVE: break; case WM_LBUTTONDOWN: break; case WM_LBUTTONUP: ShowWindow(SW_SHOW); ShowWindow(SW_RESTORE); break; case WM_RBUTTONDOWN: { POINT pt; ::GetCursorPos(&pt); // display menu starting at this point... } break; case WM_RBUTTONUP: ShowWindow(SW_MINIMIZE); ShowWindow(SW_HIDE); break; case WM_RBUTTONDBLCLK: break; default: } break; } } #endif #endif