开发者

No-MFC equivalent of AfxGetThreadState in vc++

开发者 https://www.devze.com 2022-12-13 10:31 出处:网络
I am porting a MFC applica开发者_如何学JAVAtion to Win32 one, I need to get AfxGetThreadState()->m_lastSentMsg

I am porting a MFC applica开发者_如何学JAVAtion to Win32 one, I need to get

AfxGetThreadState()->m_lastSentMsg

value in Win32.


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 ...

0

精彩评论

暂无评论...
验证码 换一张
取 消