title: How do I create window using WinMain
body: <p>I cant create a Window using WinMain.It doesnt give any errors,it just doesnt work.I even tried to copy Source code in tutorials but it didnt work.I am using :</p>
  
  <p>MinGW32
     ,Eclipse CDT Version: 8.1.2.201302132326</p>
  
  <p>The code:</p>
  
  <pre><code>#define WIN32_LEAN_AND_MEAN
  #include&lt;iostream&gt;
  #include&lt;Windows.h&gt;
  
  //Forward declarations
  bool InitMainWindow(HINSTANCE,int);
  LRESULT CALLBACK MsgProc(HWND,UINT,WPARAM,LPARAM);
  
  //Constants
  const int width=800;
  const int height=600;
  
  HWND hwnd =NULL;
  int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
  {
  //initialize window
  if(!InitMainWindow(hInstance,nCmdShow))
  
  return 1;
  //Main message loop
  MSG msg ={0};
  while(WM_QUIT != msg.message){
      if(PeekMessage(&amp;msg,NULL,0,0,PM_REMOVE))
      {
          TranslateMessage(&amp;msg);
          DispatchMessage(&amp;msg);
      }
  }
  return static_cast&lt;int&gt;(msg.wParam);
  }
  bool InitMainWindow(HINSTANCE hInstance, int nCmdShow)
  {
  //Create class window
  WNDCLASSEX wcex;
  WNDCLASS wc;
  wcex.cbSize=sizeof(wcex);
  wcex.style=CS_HREDRAW | CS_VREDRAW;
  wcex.cbClsExtra=0;
  wcex.cbWndExtra=0;
  wcex.lpfnWndProc=MsgProc;
  wcex.hInstance=hInstance;
  wcex.hIcon=LoadIcon(NULL, IDI_APPLICATION);
  wcex.hCursor=LoadCursor(NULL, IDC_ARROW);
  wcex.hbrBackground=(HBRUSH)GetStockObject(NULL_BRUSH);
  wcex.lpszClassName="LearningWinMain";
  wcex.lpszMenuName=NULL;
  wcex.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
  //Register window class
  if(!RegisterClassEx(&amp;wcex))
      return false;
  
  hwnd =CreateWindow(
      "TutorialClassName" ,
      "Tutorial Window",
      WS_OVERLAPPED|WS_SYSMENU|WS_CAPTION,
      GetSystemMetrics(SM_CXSCREEN)/2 -width/2,
      GetSystemMetrics(SM_CYSCREEN)/2 -height/2,
      width,
      height,
      (HWND)NULL,
      (HMENU)NULL,
      hInstance,
      (LPVOID*)NULL);
      if(!hwnd)
        return false;
  
      ShowWindow(hwnd,nCmdShow);
       return true;
        }
    LRESULT CALLBACK MsgProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
     {
        switch(msg)
       {
        case WM_DESTROY:
         PostQuitMessage(0);
          return 0;
  
         case WM_CHAR:
          switch(wParam)
           {
          case VK_ESCAPE:
            PostQuitMessage(0);
             return 0;
            }
          return 0;
             }
              return DefWindowProc(hwnd,msg,wParam,lParam);
         }
  </code></pre>
  
  <p>PS:The tutorial i was folowing was this:<a href="https://www.youtube.com/watch?v=ikc_I0escqU" rel="nofollow">https://www.youtube.com/watch?v=ikc_I0escqU</a></p>