Solved

how to add popup menu on right click  on systray icon

Posted on 2003-12-02
6
455 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 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.

756 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