Creating and Using Tray Icons
To create a Tray Icon, you need to call the following shell function: -
Collapse
BOOL Shell_NotifyIcon( DWORD dwMessage, PNOTIFYICONDATA pnid );
The dwMessage parameter specifies the action to be taken - NIM_ADD, NIM_DELETE, NIM_MODIFY adds, deletes and modifies tray icons respectively.
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 Application
1. Create a new VC++ dialog based project. For this example, I will call this project MyTray which will contain the CMyTrayApp and CMyTrayDlg classes.
2. Download and extract the DialogTray source code to the root of the project folder
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 CTrayDialog.
4. Replace the CMyTrayDlg base class with CTrayDialog.
Collapse
class CMyTrayDlg : public CDialog
becomes
Collapse
#include "TrayDialog.h"
class CMyTrayDlg : public CTrayDialog
5. Replace the other occurrences of CDialog in the MyTrayDlg.cpp file as follows :-
Collapse
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载