• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

sending msgs to a ccmdtarget class..

I am into the design of a digital simulator. I plan to send messages for all auspicious events occuring in the
circuit. Is it necessary that i should derive my classes from CWnd inorder to recieve a msg? If i derive from CCmdTarget, can i by anyway send msgs to it? Suppose if i am having a hidden window and if i send msgs to that,. can i route  that msgs through my set of CCmdtarget derived classes??
0
vivi052098
Asked:
vivi052098
  • 2
  • 2
1 Solution
 
NorbertCommented:
If you receive a message you can do what you want the only thing you have to do is to figure out which CCmdTarget derived class you have to call but I think thet depends on the message and therefore that should be no problem
0
 
NorbertCommented:
CCmdTarget has no window and therefore no message queue
but if you have a window that receives the messages there is no problem to reshedule them to the CCmdTarget Derived classes
The only thing the class that encapsulate the window functionality has to know is where the derived classes are

0
 
tma050898Commented:
It doesn't sound like a CCmdTarget class is what you want. CCmdTarget derived classes are used in scenarios where you want a command routed to your class. These commands are usually originated by the MFC framework. For example, in our application we have two "tools": a database editor and a forms editor. Each tool is made up of several views, dialog bars and a document. I wanted each tool to handle all the commands for its views, dialog bars and document. Therefore, both the database editor and the forms editor are CCmdTarget derived and are "inserted" into the "command routing stream" via the CMainFrame::OnCmdMsg member function.

However, in your situation where you are originating the message and have control of how and where it is sent, it would be simpler to just send the message to a CWnd derived object instead.

Tom

0
 
vivi052098Author Commented:
Tom,
     I can very well derive all my classes from CWnd but the point is that if i could derive from CCmdTarget which is somewhere higher in the heirarchy, i can reduce the memory overhead. I may have 100's of classes conected in my project and hence this problem.
    Well, i see u'r point and please tell me if i can keep one window hidden and route all messages through that...
0
 
tma050898Commented:
Before I answer that, I want to make sure that we're talking abou the same thing. When you say "route all messages" through that, do you mean can YOU send messages directly to the hidden window or do you mean that you want all messages normally handled by framework to be routed to that window instead of somewhere else???
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now