Command handler design |
Post Reply |
Author | |
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
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!
|
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
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 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
znakeeye
Senior Member Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
|
Both your answers make sense. Actually I've never caught a message in my CDocument classes .
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |