CSystemTray - Add a tray icon to your application This application implements a very simple system tray class. It shows an icon on the system tray and shows a popup menu when you right-click this icon. Minimizing the application hides the main window and removes the task button from the taskbar. Double clicking the tray icon brings the main window back to the foreground.
Using CSystemTray Add CSystemTray.cpp and CSystemTray.h to your project.
Include CSystemTray.h in the header of your application class and add a CSystemTray variable to it:
#include CSystemTray.h
class CMyApp : public CWinApp { ... CSystemTray m_SystemTray; }
In CMyApp::InitInstance() create the tray icon:
BOOL CTrayDemoApp::InitInstance() { ...
// Create the system tray icon if (!m_SystemTray.Create(WM_ICON_NOTIFY, "CSystemTray Example", LoadIcon(IDR_MAINFRAME), IDR_POPUP_MENU)) { return FALSE; }
... }
And finally be sure you to add a popup menu in your resources. That's all...
Download demo executable
Download source code This class is part of the Pablo Software Solutions MFC Extension Package - Classes Edition
|