I'm having a small issue in a simple win32 app. When I pop a messagebox prior to the window even appearing, and the user clicks on a button, the window appears for a split second and ends up behind the Visual C++ IDE window, thus forcing me to manually click it down in the taskbar to regain focus. However when I comment out the messagebox, the window has focus like it should in front of the Visual C++ IDE. I tried SetFocus(hWnd);, SetActiveWindow(hWnd);. etc., as well as a combination of em all, and it still won't appear in front of the IDE after the user clicks the button in the message box. Is there a way for me to get the Window to have focus and end up in front of the C++ IDE after clicking the messagebox button? Thanks in advance. Here's my code:

c++ Code:
  1. #include <windows.h>
  2. #include <d3d9.h>
  3.  
  4. HWND hWnd;
  5. bool Fullscreen_Enabled;
  6.  
  7. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  8.  
  9. int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
  10. {
  11.     MSG msg;
  12.     WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC, WindowProcedure, 0, 0, hInstance, NULL, NULL, NULL, NULL, "DX_TUT", NULL};
  13.     RegisterClassEx(&wc);
  14.  
  15.     if (MessageBox(hWnd, "Click Yes to go to full screen (Recommended)", "", MB_ICONINFORMATION | MB_YESNO) == IDYES)
  16.        Fullscreen_Enabled = true;
  17.  
  18.     if (Fullscreen_Enabled == true)
  19.        hWnd = CreateWindowEx (0, "DX_TUT", "DirectX9 Tutorial", WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, hInstance, NULL);
  20.     else
  21.        hWnd = CreateWindowEx (0, "DX_TUT", "DirectX9 Tutorial", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, HWND_DESKTOP, NULL, hInstance, NULL);
  22.  
  23.     ShowWindow (hWnd, nCmdShow);
  24.     while (true)
  25.     {
  26.         while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
  27.         {
  28.             if (WM_QUIT == msg.message) break;
  29.             TranslateMessage (&msg);
  30.             DispatchMessage (&msg);
  31.         }
  32.     }
  33.     return msg.wParam;
  34. }
  35.  
  36. LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  37. {
  38.     switch (msg)
  39.     {
  40.         case WM_DESTROY:
  41.             PostQuitMessage (0);
  42.             HANDLE Process;
  43.             Process = OpenProcess(PROCESS_ALL_ACCESS , true , GetCurrentProcessId());
  44.             TerminateProcess(Process , 0);
  45.             break;
  46.         default:
  47.             return DefWindowProc (hWnd, msg, wParam, lParam);
  48.     }
  49.     return 0;
  50. }