Link to home
Start Free TrialLog in
Avatar of danigraf
danigraf

asked on

Add CWnd object to a MDI project?

I use a serial port class, which requires a CWnd object to handle the messages. My project is a MDI project. I don't want to use one of the existing MDI objects to receive the messages. That means I could create a generic CWnd class (no displaying), which handles the messages.

How does that work? How can I add a new message handler class to my existing MDI project?

Or is there a easier way to do it?

I'm using NT4.0 and VC++ 6.0.

Thanks a lot
Daniel

Avatar of Shay050799
Shay050799

you have to be more specific, what the window for if you don't want to display it ?
what messages ? and where they are comming from ?
If you just want to add a cwnd object, just go into ClassWizard, choose the Add Class dropdown button, select New...

You'll get a New Class dialog. Enter class name,etc...

The critical part is the Base Class dropdown box. At the bottom is Generic CWnd. Select this, and you have your class, complete with message handlers you can implement using class wizard.


If you're doing serial port work, you may want to base your class off of CAsyncSocket, instead. It will get you the message handlers you're after.

Another option: if you're after messages that class wizard can generate - and it sounds like you are, you may want to roll your own SerialPort object and create public functions for the messages you want to handle. Then, use your active cwnd or view to capture the messages and call the methods you've put into your serial object.


Avatar of danigraf

ASKER

Sorry, I think I wasn't that specific. Here are more details about my problem:

I have a special serial port class and in that class I have to call:
m_Serial.InitPort(this, 1, 9600,'N',8,1,EV_RXCHAR,512);
The first parameter is important for message handling. It requires CWnd* pPortOwner.

What I want know is my own message handler class. I don't wanna use any classes of my MDI application. How can I implement that? Somehow, this message handler class (CWnd object?) has to know my MDI application. Otherwise it can't receive messages. I don't know how to do that.

If I pass my applications view class as message handler to InitPort(...), it works fine. But I want a separate class as message handler.

I hope that is enough information.

Thanks again
Daniel
ASKER CERTIFIED SOLUTION
Avatar of alex1234
alex1234

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial