Solved

how to add popup menu on right click  on systray icon

Posted on 2003-12-02
6
452 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

762 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

21 Experts available now in Live!

Get 1:1 Help Now