Click to See Complete Forum and Search --> : Sending/Posting Messages 2


May 28th, 1999, 10:19 AM
Hi!
I've tried to send a message from the CMainFrame to the CView when a timer event occurs. When I do so two error messages are shown and I'm forced to close the application.

This is the part of the code that sends my message:

CView* pView = GetActiveView();
HWND hView = pView->m_hWnd;
::PostMessage(hView, WM_DRAWALL, 0, 0);

I've tried to locate the error, and I believe it occurs in the first line when I try to get a pointer to the CView class. I've also tried to send the same message when you press a button and it works with no problems at all.

Is there anyone who can help me fix this?

By the way; I'm using MSVC++ 6.

All help is really appreciated!

/Richard Peterson

srinath
May 28th, 1999, 12:31 PM
hi
your problem must be due to the fact that you must have set the timer before the view is created and hence the message is posted to the view before it is being created.
make sure that your view is created before sending messaging to it.