Solved

popup menu on an icon in the system tray

Posted on 1998-06-24
6
359 Views
Last Modified: 2013-11-20
I create an icon in the system tray with:

tnd.uCallbackMessage      = MYWM_NOTIFYICON;
Shell_NotifyIcon(NIM_ADD,&tnd);

works fine...

LRESULT CMyDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {

    case MYWM_NOTIFYICON: //----- something happened on my icon in the system tray
        switch(lParam) {
        case WM_RBUTTONUP: //----- have to create a popup menu
            CMenu menu, *pPopup;
            CPoint point;

            VERIFY(menu.LoadMenu(IDR_SYSTRAY_POPUP_MENU));
            pPopup = menu.GetSubMenu(0);
            ASSERT(pPopup != NULL);
      
            GetCursorPos(&point);          

            pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
            break;
        }
        break;
    }
            
    return CDialog::WindowProc(message, wParam, lParam);
}

problem starts there:
when I right click on the icon, the menu appears, fine ! But this menu is supposed to disappear when I lButtonDown outside the menu...

the menu disappears only if I LButtonDown on my CMyDlg...

the style of this dlg is Modal, Popup, with no title bar & frame...

I am gratefull to the ones who wish to help me in my quest to a promised heaven...
0
Comment
Question by:amby
  • 5
6 Comments
 
LVL 1

Author Comment

by:amby
ID: 1318389
Edited text of question
0
 
LVL 1

Author Comment

by:amby
ID: 1318390
Edited text of question
0
 
LVL 1

Author Comment

by:amby
ID: 1318391
Edited text of question
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:amby
ID: 1318392
Edited text of question
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 60 total points
ID: 1318393
Set your dialog to the foreground before doing the trackpopupmenu:

  SetForegroundWindow();
  pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);

0
 
LVL 1

Author Comment

by:amby
ID: 1318394
Great !!

I had answers from 2 gurus of MFC !!!

I want to sleep with you too, like galfin...

PS: I would not have thought about that...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Powershell based monitoring system 2 127
Expand data scrubbing tool 13 31
java ^ examples 8 57
EvenOdd challenge 10 83
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now