From: bernd on
Hi,

I`m working at a SDI application: how is it possible to receive
ON_MESSAGE news?

I`ve one function sending a postmessage:
::PostMessage (hWnd, WM_USER_THREAD_FINISHED, (WPARAM) 12, 0);

This message can only received by an class of CWnd.... but I didn`t
have one. I`ve a CFormView, CDocument class...

In which way I`ll have the chance to receive a postmessage by the
viewclass (for example)?

best regards
Bernd
From: bernd on
On 22 Mai, 20:21, bernd <bernd.schuste...(a)googlemail.com> wrote:
> Hi,
>
> I`m working at a SDI application: how is it possible to receive
> ON_MESSAGE news?
>
> I`ve one function sending a postmessage:
> ::PostMessage (hWnd, WM_USER_THREAD_FINISHED, (WPARAM) 12, 0);
>
> This message can only received by an class of CWnd.... but I didn`t
> have one. I`ve a CFormView, CDocument class...
>
> In which way I`ll have the chance to receive a postmessage by the
> viewclass (for example)?
>
> best regards
> Bernd

ok it is working - I forgot the LRESULT in the function definition.
From: Joseph M. Newcomer on
But a a CFormView is NECESSARILY a CWnd!

Didn't you look at the class hiearchy?

More below...
On Sat, 22 May 2010 11:21:51 -0700 (PDT), bernd <bernd.schuster12(a)googlemail.com> wrote:

>Hi,
>
>I`m working at a SDI application: how is it possible to receive
>ON_MESSAGE news?
>
>I`ve one function sending a postmessage:
>::PostMessage (hWnd, WM_USER_THREAD_FINISHED, (WPARAM) 12, 0);
****
Why are you using an HWND here? CWnd::PostMessage works just as well, and doesn't require
getting the HWND.

Is there some significance to the WPARAM being 12? What does 12 mean?
****
>
>This message can only received by an class of CWnd.... but I didn`t
>have one. I`ve a CFormView, CDocument class...
****
However, a CDocument is NOT a CWnd, and you cannot PostMessage to a CDocument unless you
do really weird things such as dealing with how WM_COMMAND routing is handled. Not really
something you want to do.

If you really need to post a message to the CDocument class, the typical technique is to
have the CDocument class instantiate an invisible CWnd-derived subclasss which it uses as
a message sink. This CWnd-derived class has a pointer to your CDocument-derived class,
and can even be a friend class of the CDocument so you don't need to make the private
interface public.
****
>
>In which way I`ll have the chance to receive a postmessage by the
>viewclass (for example)?
***
A CView is also necessarily a CWnd. Look at the class hiearchies.
joe
****
>
>best regards
>Bernd
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
 | 
Pages: 1
Prev: SubClass CEdit Question
Next: VS 2010 and VS 2008