Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Context menu help

Posted on 2001-08-08
5
Medium Priority
?
381 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 225 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

636 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