Solved

how to add popup menu on right click  on systray icon

Posted on 2003-12-02
6
453 Views
Last Modified: 2010-08-05
I have icon in systray area. How can I add popup menu when user right clicks on my icon?
0
Comment
Question by:amakalski
  • 3
  • 3
6 Comments
 

Author Comment

by:amakalski
ID: 9859665
MFC code is fine
0
 
LVL 86

Expert Comment

by:jkr
ID: 9859757
Check out the sample at http://www.codeproject.com/shell/systemtray.asp - it comes with all the code you need
0
 

Author Comment

by:amakalski
ID: 9860268
@jrk,
thanks, but I already created icon in Systray using Shell_NotifyIcon (the article introduces whole class for that). All I need is to know how to create popup menu whenever user right-clicks on the icon and where to process menu commands
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:jkr
ID: 9860306
>>All I need is to know how to create popup menu

That is covered in the sample also, which was the main reason for me to post it.
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 9860707
BTW, if you need another (MFC) sample on how to show a menu, take a lok at http://www.codeguru.com/shell/systemtray.shtml 
0
 

Author Comment

by:amakalski
ID: 9861980
Oh well, after an extensive lookup in the last sample I finally compiled code that I need to create and run popup menu:

      CMenu menu_bar;
      menu_bar.LoadMenu(IDM_POPUP_MENU);
      CMenu *popup_menu = menu_bar.GetSubMenu(0);
      assert( popup_menu != NULL );

      // Display and track the popup menu
      CPoint pos;
      GetCursorPos(&pos);

      this->SetForegroundWindow();  
      popup_menu->TrackPopupMenu(0,pos.x, pos.y, this, NULL);
      // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly"
    this->PostMessage(WM_NULL, 0, 0);

      menu_bar.DestroyMenu();
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

863 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

22 Experts available now in Live!

Get 1:1 Help Now