dispatches incoming messages under console

I have a console program. It need post message to internal window. I need dispatche the incoming sent messages and send to window process function.
I have create a thread. Inside thread, I have implemented the following code. But it did not work. Does anyone know how to fix this?

void ThreadRun()
{
MSG msg;

if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if( !GetMessage( &msg, NULL, 0, 0 ) )
return;

TranslateMessage( &msg );
DispatchMessage( &msg );

}
}

The ThreadRun will be called inside thread every 100 ms.
[652 byte] By [stevesj] at [2007-11-18 17:45:08]