Solved

Context menu help

Posted on 2001-08-08
5
376 Views
Last Modified: 2013-11-20
I have a CListCtrl-derived class which instantiates a context menu. The ListCtrl object is located within a form view. How do I allow the view class to process the menu selection rather than the CListCtrl-derived class? ON_COMMAND(ID_PROP_TEST, OnPropTest) handled by view class.
0
Comment
Question by:sgraves66
[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
  • 2
  • 2
5 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 6367034
Hi sgraves66,

do you use CMenu::TrackPopupMenu in the derived list class's OnContextMenu to
display the menu? If so simply pass a pointer to the view instead of the pointer
to the list as 4th parameter...

hope that helps,

ZOPPO
0
 
LVL 1

Author Comment

by:sgraves66
ID: 6367073
The handle arg sunk in right after I posted this -- Didn't think about it the first go round :)

My next task is to disable menu items based upon the mouse cursor in relation to the items (all in report view). I've added remove / remove selected / remove all to the popup menu. I just need to disable "remove" if no items are present below the mouse cursor (in whitespace). How can I reference the popup menu from the view class in order to make these changes?
0
 
LVL 1

Author Comment

by:sgraves66
ID: 6367074
Inc. points for 2 question...
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 75 total points
ID: 6367109
Hi again,

you can add a ON_COMMAND_UPDATE_UI handler for that menu item in your view
class and in there for the best call a function you implement in the list class which
returns TRUE if a item is beyond the mousecursor (how to do this depends a little
on other things you do in OnContextMenu(), i.e. if the selection changes if you click
with right mouse button on an item or not) and FALSE otherwise. With this returned
value you can call 'pCmdUI->Enable( <theReturnedValue> )' to en-/disable the item.

ZOPPO
0
 
LVL 1

Expert Comment

by:Tim_Musschoot
ID: 6371610
Hello,

You can repost a message (the same perhaps) to the View class, and also add a message handler there...

Tim Musschoot
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

707 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