Solved

Context menu help

Posted on 2001-08-08
5
370 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
  • 2
  • 2
5 Comments
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
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
Comment Utility
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
Comment Utility
Inc. points for 2 question...
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 75 total points
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

763 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

9 Experts available now in Live!

Get 1:1 Help Now