Solved

popup menu on an icon in the system tray

Posted on 1998-06-24
6
363 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
format the code in java 6 101
changeXy challenge 13 87
unix example issues 18 98
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 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