title: Encapsulate Windows message loop into a DLL
body: <p>I would like to have a DLL with window creation and management code in a way that the developer could just add a named main.h header and load the DLL to be able to instance a window.</p>
  
  <pre><code>#include "dllheader.h" 
  
  void user_main();
  
  main = user_main; // attach user main to the dll callback
  
  int user_main() {
      Window *w = new Window();
  }
  </code></pre>
  
  <p>on the DLL side the code should look like</p>
  
  <pre><code>void (*main)() = NULL;
  
  int WinMain(...) {
     if(main)
         main(); // call the user defined funcion
     while(!done) {
         if(messageWaiting()) {
             processMessage();
         }
     }
  
  }
  </code></pre>
  
  <p>Why? because I want to deploy a window wrapper and avoid to have the user writting the WinMain entry point. But a DLL project have a DLL main and a win32 project that uses a DLL complaim if linker doesnt find a winMain entry point.</p>
  
  <p>Is there a know solution for this kind of arrange?</p>