Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - Command handler design
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Command handler design

 Post Reply Post Reply
Author
Message
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: Command handler design
    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!
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 08 March 2008 at 3:38am
Both your answers make sense. Actually I've never caught a message in my CDocument classes .
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.