title: PlaySound() keeps playing my .wav after WM_DESTROY and a DrawText Issue
body: <p>I am experimenting on Windows 7 64 bit OS with win32 API.When i run my Program on debug mode my window appears but i have 2 bugs. Firt things first here is my api code modified from Charles Petzold book Ch3:</p>
  
  <pre><code>#include&lt;Windows.h&gt;
  #include&lt;mmsystem.h&gt;
  
  
  
  
  
  LRESULT CALLBACK HandleMyWindowsClassMessages(HWND WindowHandle, UINT Message, WPARAM wParam, LPARAM lParam);
  
  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreviousInstance, PSTR szCmdLine, int iCmdShow)
  {
  
      WNDCLASSEX MyWindowsClass;
      static wchar_t szMyWindowsClassName[] = TEXT("The Name of My Window Class");
      static wchar_t szAppName[] = TEXT("AppName");
      HWND myWindowHandle;
      MSG msg;
  
      MyWindowsClass.hInstance = hInstance;
      MyWindowsClass.style = CS_HREDRAW | CS_VREDRAW;
      MyWindowsClass.lpfnWndProc = HandleMyWindowsClassMessages;
      MyWindowsClass.lpszClassName = szMyWindowsClassName;
      MyWindowsClass.cbSize = sizeof(WNDCLASSEX);
      MyWindowsClass.cbClsExtra = 0;
      MyWindowsClass.cbWndExtra = 0;
      MyWindowsClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
      MyWindowsClass.hCursor = LoadCursor(NULL, IDC_ARROW);
      MyWindowsClass.hIcon = LoadIcon(NULL, IDI_SHIELD);
      MyWindowsClass.hIconSm = NULL;
      MyWindowsClass.lpszMenuName = NULL;
  
      if (!RegisterClassEx(&amp;MyWindowsClass))
      {
          MessageBoxEx(0, TEXT("This Programm Requires WINNT!"), szMyWindowsClassName, MB_ICONERROR, 0);
          return(0);
      }
  
      myWindowHandle = CreateWindowEx(
          WS_EX_OVERLAPPEDWINDOW,
          szMyWindowsClassName,
          szAppName,
          WS_OVERLAPPEDWINDOW,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          CW_USEDEFAULT,
          NULL,
          NULL,
          hInstance,
          NULL);
  
      ShowWindow(myWindowHandle, iCmdShow);
      UpdateWindow(myWindowHandle);
  
      while (GetMessage(&amp;msg, myWindowHandle, 0, 0))
      {
          TranslateMessage(&amp;msg);
          DispatchMessage(&amp;msg);
      }
  
  
      return(msg.wParam);
  }
  
  LRESULT CALLBACK HandleMyWindowsClassMessages(HWND WindowHandle, UINT Message, WPARAM wParam, LPARAM lParam)
  {
      //wchar_t szGreeting[] = TEXT("Heeeey");
      HDC hdc;
      PAINTSTRUCT ps;
  
  
      switch (Message)
      {
  
          case WM_CREATE:
          {
              PlaySound(TEXT("D:\\mp3\\aywy._&amp;_EphRem_-_Adderall.wav"), NULL, SND_FILENAME | SND_ASYNC);
              return(0);
          } break;
  
          case  WM_PAINT:
          {
              hdc = BeginPaint(WindowHandle, &amp;ps);
              DrawText(hdc, TEXT("Hello Win 7!!!"), -1, &amp;ps.rcPaint, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
              //TextOut(hdc, 0, 0, szGreeting, (int)wcslen(szGreeting));
              EndPaint(WindowHandle, &amp;ps);
              return(0);
          }break;
  
          case WM_DESTROY:
          {
              PostQuitMessage(0);
              return(0);
          }break;
  
      }
  
      return(DefWindowProc(WindowHandle, Message, wParam, lParam));
  }
  </code></pre>
  
  <p>Bug1:PlaySound keeps playing the wav even when i have closed-destroyed the Window.When I used the original example with plain WNDCLASS the bug dissapeared!
  So I must be doing something wrong using WNDCLASSEX ???.
  Also in this bug to end execution of debbuging I have to press <code>Shift+F5</code>.</p>
  
  <p>Bug2:TextOut vs DrawText
  Info:I have only 1 screen.I program on my laptop.
  When I use drawText and the text in my window goes out of my desktop screen borders the text just doesnt update correclty.
  When I use TextOut the bug dissapears!!!
  Why???</p>
  
  <p>Below i have some pitures ordered to explain this.</p>
  
  <ol>
  <li>The Program starts in debug mode
  <img src="https://i.stack.imgur.com/Xwpav.jpg" alt="Program start"></li>
  <li>Moving the window out of Desktop borders(including the displayed text)
  <img src="https://i.stack.imgur.com/Fkh1Z.png" alt="enter image description here"></li>
  <li>Moving the window back inside my desktop area(the text has been mutated)
  <img src="https://i.stack.imgur.com/qEqQK.png" alt="Window is back again"></li>
  <li>Window is destroyed and sound will keep playing even when the wav ends.
  <img src="https://i.stack.imgur.com/WrTgk.png" alt="Window Destroyed"></li>
  </ol>
  
  <p>Any help in any of the 2 bugs would be greatly appreciated.</p>
  
  <p>2nd version of my WndProc:</p>
  
  <pre><code>LRESULT CALLBACK HandleMyWindowsClassMessages(HWND WindowHandle, UINT Message, WPARAM wParam, LPARAM lParam)
  {
      //wchar_t szGreeting[] = TEXT("Heeeey");
      HDC hdc;
      PAINTSTRUCT ps;
      RECT rc;
  
      rc.left = 50; rc.top = 100; rc.right = 200; rc.bottom = 200;
  
      switch (Message)
      {
  
      case WM_CREATE:
      {
          PlaySound(TEXT("D:\\mp3\\aywy._&amp;_EphRem_-_Adderall.wav"), NULL, SND_FILENAME | SND_ASYNC);
          return(0);
      } break;
  
      case  WM_PAINT:
      {
          hdc = BeginPaint(WindowHandle, &amp;ps);
          DrawText(hdc, TEXT("Hello Win 7!!!"), -1, &amp;rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
          //TextOut(hdc, 0, 0, szGreeting, (int)wcslen(szGreeting));
          EndPaint(WindowHandle, &amp;ps);
          return(0);
      }break;
  
      case WM_DESTROY:
      {
          PlaySound(NULL, NULL, SND_FILENAME | SND_ASYNC);
          PostQuitMessage(0);
          return(0);
      }break;
  
      }
  
      return(DefWindowProc(WindowHandle, Message, wParam, lParam));
  }
  </code></pre>