I've recently been trying to implement a console like interface using modeless dialog boxes. The interface has a Create function which should create a new modeless dialog and allow it to function in more or less the same way as a console. The problem is that I don't want someone using the interface to have to implement a message loop; I'd like it self contained. So I tried creating a thread for the dialogs message loop. The problem with that was that the message loop and the window must be created in the same thread. To get around this, I changed things to create a thread each time Create is called and that thread creates a new dialog box and then goes into the message loop. I thought this should work but the message loop isn't working correctly and the dialogs dont respond to anything. Below is the code I use to create the threads and dialogs as well as how I check the messages. Currently, I am not doing anything in my dialogProc, so I have not included it. Additionally, I don't think it matters, but the implementation of this class is in a DLL.

First, the call to create the console
Code:
bool Console::CreateConsole(void)
{
   // hDialog and bConsole are class members		
   if(hDialog || bConsole)
      return false;

   if(!(hRichEdit = LoadLibrary("RichEd20.dll")))
      return false;

   if(!bConsole)
   {
      // Spawn a new thread
      hThread = _beginthread(ThreadLoop, 0, this);
      bConsole = true;
   }

   return true;
}
The thread code
Code:
void CDECL ThreadLoop(void* vp)
{
   MSG msg;
   msg.message = WM_NULL;

   Console* p = (Console*)vp;

   // dllhInst is stored globably when the DLL is loaded
   p->hDialog = CreateDialog(dllhInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);

   while(msg.message != WM_QUIT)
   {
      if(GetMessage(&msg, 0, 0, 0))
      {
         if(p->hDialog == NULL || !IsDialogMessage(p->hDialog, &msg))
            {
               TranslateMessage(&msg);
               DispatchMessage(&msg);
            }
      }
   }
}
I'd appreciate any advice or suggestions you may have. I'm also open to any alternative implementations as long as they allow me to create multiple dialogs and they dont require additional code to be written by the user of the interface. Thanks for any help you can offer.