Post by MeI canr make any sense out of your information.
What do I need to add to my Class to get the main dialog to display the
message?
What do I need to add to the main Dialog to display the message sent by
Class?
Post by Mikel LuriPost by Mec_Info.SetWindowText("Processing, Please wait..");
How do I display a message on the main Dialog from within another class?
Thanks.
I would keep displaying it the same way and ask the question "how do I
tell the main dialog to display a message from another class?".
And the answer to that could be "by sending a message to it".
I would go for registered windows messages (check
http://www.flounder.com/messages.htm#Registered Window Messages)
It depends on how you've got it implemented (i.e. what's your Class, how
it relates to the main dialog...), but basically:
- Define the message somewhere, probably in your class' .h file (see
"Defining messages in the link provided in my previous message)
#define UWM_SET_MESSAGE_MSG _T("UWM_COLOR_IT-<your_own_GUID_here>")
- Create the DECLARE_USER_MESSAGE macro and make it visible to your
class and the dialog (I would do a .h file for it and include it both
your class and the dialog, or directly add in stdafx.h)
- Add DECLARE_USER_MESSAGE(UWM_SET_MESSAGE) to your class and dialog's
cpp files.
- Add a handler for the message in the dialog and set the text there
- You need a function with a message handler signature LRESULT
MyHandler (WPARAM, LPARAM). In it, you set the text, passed as a
parameter, to the static control
- Add a message map entry ON_REGISTERED_MESSAGE(UWM_SET_MESSAGE,
MyHandler)
- In your class, when you want your text displayed, send a message to
the dialog. How you do that will depend on how is everything set.
If your class is a child window of the dialog, you would do:
GetParent()->SendMessage(UWM_SET_MESSAGE, 0, yourstring);
Or you could have a CWnd* member in your class, pointing to your dialog,
and you would do:
m_Dialog->SendMessage(UWM_SET_MESSAGE, 0, yourstring);
Not knowing exactly what you are doing, I can't give many details, or
maybe the solution would be different. For example, instead of sending
the string in the message, maybe it would be better to send a message
saying "X has happened" and have the dialog display a message for that
event.
There are many articles with code in Joe's site
(http://www.flounder.com/mvp_tips.htm) and in many of them he uses these
techniques. That's were I learned them