|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThis article illustrates the use of Creating and Using Tray IconsTo create a Tray Icon, you need to call the following shell function: - BOOL Shell_NotifyIcon( DWORD dwMessage, PNOTIFYICONDATA pnid ); The The pnid parameter is used to customize, create, delete and obtain data from the Tray Icon. (See the MSDN Library for more details about this structure.) Creating The Application1. Create a new VC++ dialog based project. For this example, I will call this
project 2. Download and extract the 3. From the Project->Add To Project menu, select Files and
then select TrayDialog.h and TrayDialog.cpp. This will add a new class to your project named 4. Replace the class CMyTrayDlg : public CDialog becomes #include "TrayDialog.h" class CMyTrayDlg : public CTrayDialog 5. Replace the other occurrences of CMyTrayDlg::CMyTrayDlg(CWnd* pParent /*=NULL*/) : CDialog(CMyTrayDlg::IDD, pParent) becomes CMyTrayDlg::CMyTrayDlg(CWnd* pParent /*=NULL*/) : CTrayDialog(CMyTrayDlg::IDD, pParent) 6. Create a menu resource and name it 7. In the
TraySetIcon(IDR_MAINFRAME);
TraySetToolTip("ToolTip for tray icon");
TraySetMenu(IDR_MENU1);
8. Modify the 9. Build and run the application NB : To add tray menu item handlers use the class wizard. Displaying the tray icon all the timeSimply add a The events that occur in the tray are captured through the following functions:
virtual void OnTrayLButtonDown(CPoint pt);
virtual void OnTrayLButtonDblClk(CPoint pt);
virtual void OnTrayRButtonDown(CPoint pt);
virtual void OnTrayRButtonDblClk(CPoint pt);
virtual void OnTrayMouseMove(CPoint pt);
Feel free to add more events or to improve on these ones.
|
||||||||||||||||||||||