Solved

Context menu help

Posted on 2001-08-08
5
375 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 99
Best tools for Backup and restore of Wordpress site 6 58
Path of Workbook 3 87
Thin secure Windows 10 5 115
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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