Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After installing an icon to the system tray by Shell_NotifyIcon, this icon become the extension of your dialog UI. When the user interact with this icon, the UI messages will be re-directed to your dialog by the OS automatically.</p> <p>To serve these user messages you needs to perform few steps:</p> <p>(1) Add a message handler definition (ON_MESSAGE(WM_TRAY_NOTIFY, OnTrayNotify)) inside the (.cpp) file. Must be inside the BEGIN_MESSAGE_MAP/END_MESSAGE_MAP block:</p> <pre><code>BEGIN_MESSAGE_MAP(CTestDlg, CDialog) //{{AFX_MSG_MAP(CTestDlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ... //}}AFX_MSG_MAP ON_MESSAGE(WM_TRAY_NOTIFY, OnTrayNotify) END_MESSAGE_MAP() </code></pre> <p>(2) Add a message handler implementation in the (.cpp) file, to perform the actual work</p> <pre><code>void CTestDlg::OnTrayNotify(UINT nID, LPARAM lEvent) { if (nID==TRAYICON_ID1) { // handle messages here if (lEvent==WM_LBUTTONDBLCLK) { // do left button double click, usually restore application } if (lEvent==WM_RBUTTONUP) { // do right button up, usually popup a menu at clicked location } } } </code></pre> <p>(3) Add a prototype definition of this message handler (afx_msg void OnTrayNotify(UINT nID, LPARAM lEvent);) inside the (.h) file. Must be inside the BEGIN_MESSAGE_MAP/END_MESSAGE_MAP block:</p> <pre><code>// Generated message map functions //{{AFX_MSG(CTestDlg) virtual BOOL OnInitDialog(); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); ... //}}AFX_MSG afx_msg void OnTrayNotify(UINT nID, LPARAM lEvent); DECLARE_MESSAGE_MAP() </code></pre> <p>(4) Add definition inside (.h) file</p> <pre><code>#define WM_TRAY_NOTIFY WM_USER+567 #define TRAYICON_ID1 0x1234 </code></pre> <p>The code above is assuming:</p> <ul> <li>The dialog name is CTestDlg, change it to your dialog name</li> <li>The user-callback-message identifier (uCallbackMessage) used to setup Shell_NotifyIcon is WM_TRAY_NOTIFY</li> <li>The identifier of the tray icon (uID) sed to setup Shell_NotifyIcon is TRAYICON_ID1</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload