Solved

popup menu on an icon in the system tray

Posted on 1998-06-24
6
362 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 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