Print Page | Close Window

Command handler design

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: General Discussion
Forum Description: Topics Related to Visual C++ MFC Development in General
URL: http://forum.codejock.com/forum_posts.asp?TID=9819
Printed Date: 30 September 2024 at 2:45am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Command handler design
Posted By: znakeeye
Subject: Command handler design
Date Posted: 07 March 2008 at 2:57am

I have a frame with a view, with a report control. On my menu I have five commands that somehow alter this report control. These commands are also accessable via a right-click menu in the report control.

1) Where should I put my command handlers? In the frame, the view or in the report control itself?
2) When showing the right-click menu, should I rely on the command handlers or should I explicitly check the return value of TrackPopupMenu()?
 
Are there any guidelines for this?
Thanks!



Replies:
Posted By: mgampi
Date Posted: 07 March 2008 at 6:44am
Hi;
the standard MFC message routine is first frame, then view then document if you have a doc/view architecture.
In most cases I handle the messages in my CDocument implementation, because the commands more or less manipulate the data I present in my views/controls.
When I don't have doc/view architecture, I handle command messages at place where they occure. The only difference here is, when the data is controlled by the parent/owner of the control.
 
To your second question:
Most of the time (95 out of 100) I use command handlers for popup menus also. IMHO this leads to a more readable and maintainable code.


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017


Posted By: znakeeye
Date Posted: 08 March 2008 at 3:38am
Both your answers make sense. Actually I've never caught a message in my CDocument classes .



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net