-
May 17th, 2006, 08:50 AM
#1
PumpMessage
I have this code in VC6 MFC:
Code:
BOOL CSimEngineApp::PumpMessage()
{
ASSERT_VALID(this);
//if (!::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_REMOVE))
if (!::PeekMessage(&m_lastSentMsg, NULL, NULL, NULL, PM_REMOVE))
{
return TRUE;
}
if (m_msgCur.message == WM_QUIT)
{
#ifdef _DEBUG
if (afxTraceFlags & traceAppMsg)
TRACE0("CWinThread::PumpMessage - Received WM_QUIT.\n");
m_nDisablePumpCount++; // application must die
// Note: prevents calling message loop things in 'ExitInstance'
// will never be decremented
#endif
return FALSE;
}
#ifdef _DEBUG
if (m_nDisablePumpCount != 0)
{
TRACE0("Error: CWinThread::PumpMessage called when not permitted.\n");
ASSERT(FALSE);
}
#endif
// process this message
if (m_msgCur.message != WM_KICKIDLE && !PreTranslateMessage(&m_msgCur))
{
::TranslateMessage(&m_msgCur);
::DispatchMessage(&m_msgCur);
}
return TRUE;
}
I am trying to use this code in 2005, but it shouts that m_msgCur and m_nDisablePumpCount are not declared. Did anyone solve this?
Last edited by jhammer; May 17th, 2006 at 09:16 AM.
-
May 17th, 2006, 12:19 PM
#2
Re: PumpMessage
And are they declared ? are these variables class member ?
-
May 17th, 2006, 04:53 PM
#3
Re: PumpMessage
Maybe before trying to solve "problem", you explain what exactly are you trying to do?
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
April 6th, 2007, 04:59 AM
#4
Re: PumpMessage
m_msgCur and m_nDisableCount are both undocumented members of CWinThread in VC++6.
Since CWinApp is derived from CWinThread and your CSimEngineApp function is derived form CWinApp these are also members of your CSimEngineApp class.
The difference to the standard implementation of PumpMessage() is (see THRDCORE.CPP):
if (!::GetMessage(&m_msgCur, NULL, NULL, NULL))
{...do the rest
}
was replaced by
if (!::PeekMessage(&m_lastSentMsg, NULL, NULL, NULL, PM_REMOVE))
{ return; }
... do the rest
So the overriden version would return emediately if no message is available and would skip checks like reentry check ( if (m_nDisablePumpCount != 0)),...
Would, because PumpMessage() is not called if no message is available (at least not by the CWinThread::Run() standard implementation).
When pump message is called, the m_msgCur strucure is already initialized!! (with the same contents that m_lastSentMsg will get) and PumpMessage behaves normally. GetMessage is only called to remove the message from the queqe.
So basically it seems that the change just takes care that the acutal message is also available in m_lastSentMsg and not only in m_msgCur.
I don't think that the function CWinThread::PumpMessage() was intended to be overridden.
There are some backdraws in the implementation and I can imagine, that the whole mechanism was implemented differently in ??2005 MFC?? thus eliminating the member variables that you are missing.
If you use the PreTranslateMessage function of your application to store the message in m_lastSentMsg you should have the same effect without changing MFC code.
Regards
Leo
Last edited by Chilli71; April 6th, 2007 at 05:34 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|