Solved

Context menu help

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.

790 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