title: Win32 DLL Window not showing
body: <p>I've recently come up with some code that logic (and various places on the internet) says should work.
  When injecting my Win32 DLL into any program though to test it, the Window I've create doesn't appear. I have no idea why this is, my code is as follows:</p>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include "stdafx.h"
  #include "resource.h"
  #include &lt;tchar.h&gt;
  
  HWND PGHWND;
  
  BOOL CALLBACK EventHandler(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
  {
      return 0;
  }
  
  DWORD WINAPI MainWin(HMODULE hMod)
  {
      DialogBox(hMod, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)EventHandler);
      ExitThread(0);
      return 0;
  }
  
  void GetWnd()
  {
      DialogBox(0,MAKEINTRESOURCE(IDD_DIALOG1),0,0);
      for(;;)
      {
          PGHWND = FindWindow(NULL, "3D Pinball for Windows - Space Cadet");
          if(PGHWND)
          {
              break;
          }
      }
  }
  
  __declspec(dllexport) bool __stdcall DllMain(HMODULE hModule,DWORD Reason,LPVOID lpv) //DllMain
  {      
      switch (Reason){ //What happened?
          case DLL_PROCESS_ATTACH: //Did the DLL attach?
              DisableThreadLibraryCalls(hModule); //Disable THREAD_ATTACH and THREAD_DETACH
              CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainWin, hModule, 0, NULL); //Start the thread to create the dialog
              CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&amp;GetWnd,NULL,0,NULL); //Start our thread to get the window
              MessageBox(0, _T("This program was created by Joe Savage"), _T("Pinball Modifications!"), 0);
              break;
          break;
      }
      return true;
  }
  </code></pre>
  
  <p><strong>Main.rc</strong></p>
  
  <pre><code>// Generated by ResEdit 1.5.4
  // Copyright (C) 2006-2010
  // http://www.resedit.net
  
  #include &lt;windows.h&gt;
  #include &lt;commctrl.h&gt;
  #include &lt;richedit.h&gt;
  #include "resource.h"
  
  
  
  
  //
  // Dialog resources
  //
  LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
  IDD_DIALOG1 DIALOG 0, 0, 55, 24
  STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
  CAPTION "Dialog"
  FONT 8, "Ms Shell Dlg"
  {
      DEFPUSHBUTTON   "OK", IDOK, 3, 3, 50, 14
  }
  </code></pre>
  
  <p><strong>resource.h</strong></p>
  
  <pre><code>#ifndef IDC_STATIC
  #define IDC_STATIC (-1)
  #endif
  
  #define IDD_DIALOG1                             100
  </code></pre>