Solved

how to add popup menu on right click  on systray icon

Posted on 2003-12-02
6
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
FMX StringGrid1->Canvas->FillRect Problem 3 219
Finding Divisors 5 60
maximize the sum of fractions 33 74
why doesn't assert terminate here? 2 18
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

737 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