title: Enable Close Button for Dialog c++ winapi
body: <p>Having simple window, button which opens dialog. But I want to add close button to it. </p>
  
  <p>I have tried to add close button with adding WM_SYSMENU, with adding EnableMenuItem, but it didn't work:</p>
  
  <p>Minimal code is:<br>
  resource.rc:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>
  IDD_FORMVIEW DIALOGEX 0, 0, 178, 86
  STYLE DS_SETFONT | DS_CONTROL | WS_VISIBLE | WS_SYSMENU
  EXSTYLE WS_EX_OVERLAPPEDWINDOW
  CAPTION "TEST"
  FONT 12, "Microsoft Sans Serif", 400, 0, 0xCC
  BEGIN
      CTEXT           "Test",IDC_STATIC,46,4,74,8,0,WS_EX_CLIENTEDGE
  END
  </code></pre>
  
  <p>resource.h:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#define IDD_FORMVIEW                    101
  </code></pre>
  
  <p>Test.cpp:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>hwndButton = CreateWindowW(L"BUTTON",
              L"ENTER",
              WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON | WS_CLIPSIBLINGS,
              605, 510, 255, 45,
              hWnd, (HMENU)1, NULL, NULL);
  case WM_COMMAND:
      {
          switch (LOWORD(wParam)) {
  
  
  case 2: {
          if (hwndHTDW == NULL) {
  
  hwndHTDW = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_FORMVIEW), hWnd, DialogProc);    
  
  ShowWindow(hwndHTDW, SW_SHOW);
  UpdateWindow(hwndHTDW);
  }
  }
  break;
          }
  }
  
  {
  
  
      switch (msg) {
      case WM_INITDIALOG: {
          EnableMenuItem(GetSystemMenu(hwnd, FALSE), SC_CLOSE,
              MF_BYCOMMAND | MF_ENABLED);
  
          return TRUE;
      }
          break;
  
  
      default:
          return FALSE;
  
      }
  
      return TRUE;
  </code></pre>