views:

91

answers:

1

Hi; I am porting a MFC application to Win32 one, I need to get

AfxGetThreadState()->m_lastSentMsg

value in Win32, I searched but could not find anything, your help is appreciated.

A: 

Well all MFC is doing is recording what the last message it received was in a class. I'm sure you could add something like this to your thread message pumps ...

Edit: Also its worth looking at __declspec( thread ) for defining a "global" in the thread local storage. This is what MFC does ...

Edit: You'll have a message pump. If you first declare a variable similar to the following:

__declspec( thread ) MSG g_LastMsg = 0;

And then you need to change your message pump in each thread to something like this:

MSG msg;
while( GetMessage( &msg, NULL, 0, 0 ) )
{
            g_LastMsg = msg;
 TranslateMessage( &msg );
 DispatchMessage( &msg );
}

Now any time you want to see what the last message "pumped" was just check the g_LastMsg variable ...

You could also build the message struct from inside your Window procedures if you prefer. Entirely up to you ...

Goz
Well, in fact I am not that pro on MFC so what where should I record last message?
whoi