Re: PostMessage and unprocessed messages
"Joseph M. Newcomer" <email@example.com> ha scritto nel messaggio
Now I'm curious why you are using ::PostMessage and where the HWND
'window' is defined. It
must not be a global or static variable, because usage of a static or
global varable is
not justified here.
They are member variables of a thread class.
I defined a custom thread class (call it Thread) for the background worker
thread, which stores the HANDLE of thread, the thread ID, and also HWND of
target window (the "receiver" window, to where messages are sent using
Neither global nor static variables.
You seem to indicate the thread function takes no parameters, but
that is incorrect, because it always takes an LPVOID.
Again, my custom Thread class has a static method which is the classical
ThreadProc that I pass to ::CreateThread.
Moreover, this class has a non-static method, which is called by static
thread proc, e.g.:
: m_thread(NULL), m_ID(0) ...
if ( m_thread != NULL )
::CloseHandle( m_thread );
m_thread = NULL;
m_ID = 0;
m_thread = ::CreateThread(
(LPVOID *) this,
if ( m_thread == NULL )
return false; // failed
// All right
ASSERT( m_thread != NULL );
::ResumeThread( m_thread );
static DWORD WINAPI StaticThreadProc( LPVOID param )
Thread * me = (Thread *)param;
... the thread long job here
Actually, I have a base thread class that has a *pure* virtual protected
ThreadProc() method, and all thread classes must derive from this class, and
implement their own ThreadProc (of course, this base class has a virtual
class MyThread : public BaseThread
virtual DWORD ThreadProc()
I use ::PostMessage because I'm writing this project without MFC, instead
I'm using ATL/WTL.
However I'm asking here because this is the newsgroup where I can get your
help and wise advice... (and mapping MFC <-> Win32 is not that hard in this