title: Why is SetWindowText not working any more?
body: <p>I have code that was 1st developed with Visual C++ Version 1.52 (working and self taught). A couple of years ago I adapted it with Visual Studio and got it working. I am now trying it again with Visual Studio 2022 but I can't get the SetWindowText function to work as it had. It does change the parent window title text but it is gobbledygook. I assume it's a UNICODE problem but so far haven't been able to negotiate the maze of explanation. It is set in a wizard generated MFC document. I'm including the function. Any suggestions?</p>
  <pre class="lang-cpp prettyprint-override"><code>void CTICTACView::Game()
  {
  
      CWnd* p_Wnd = GetParent();
      const char* capt = &quot;TIC TAC TOE&quot;;
      const char* gm = &quot;GAME!&quot;;
      if (!game)
          p_Wnd-&gt;SetWindowText((LPCTSTR)capt);
      else
          p_Wnd-&gt;SetWindowText((LPCTSTR)gm);
  
  }
  </code></pre>
  <p>After constructing Frankenstein from bits and pieces, this is what I finally got to work. Thank you everybody.</p>
  <pre><code>void CTICTACView::Game()
  {
    CWnd* p_Wnd = GetParent();    
    const wchar_t* capt =_T(&quot;TIC TAC TOE&quot;);
    const wchar_t* gm = _T(&quot;GAME!&quot;);
    if (!game)
      p_Wnd-&gt;SetWindowText((LPCWSTR)capt);
    else
      p_Wnd-&gt;SetWindowText((LPCWSTR)gm);
  }
  </code></pre>