title: ENABLE_VIRTUAL_TERMINAL_PROCESSING and DISABLE_NEWLINE_AUTO_RETURN failing
body: <p>The point was to make this little multiplayer game in the terminal, applying some basic graphics concepts to get a grasp on how it works and the maths behind it.</p>
  
  <p>Note I wish to do this for fun and I am fully aware there are way better alternatives out there to using a terminal.</p>
  
  <p>I'd need a console I could write to, so the point was to remove scroll bars and have the whole buffer printed to the screen.  </p>
  
  <p>But because of the carriage return when characters get written to the end of the previous line:
  <a href="https://i.stack.imgur.com/89Agw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/89Agw.png" alt="carriage return"></a></p>
  
  <p>this would look overall ugly:</p>
  
  <p><a href="https://i.stack.imgur.com/Az28V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Az28V.png" alt="enter image description here"></a></p>
  
  <p>After trying for about 3 hours to get this working through SetConsoleMode, I asked about it in a discord.</p>
  
  <p>The answer I got was this:</p>
  
  <pre><code>void main( )
  {
      auto h = GetStdHandle( STD_OUTPUT_HANDLE );
  
      DWORD mode = 0;
      GetConsoleMode( h, &amp;mode );
  
      mode |= DISABLE_NEWLINE_AUTO_RETURN | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
  
      puts( SetConsoleMode( h, mode ) ? "Win" : "Loss" );
  
      char * buf = new char[ 200*2 ];
      memset( buf, 0, 200*2 );
      memset( buf, 'A', 120*2 );
      std::cout &lt;&lt; ( buf );
  
      getchar( );
  }
  </code></pre>
  
  <p>with this result:
  <a href="https://i.stack.imgur.com/9MPuX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9MPuX.png" alt="Code Result"></a></p>
  
  <p>At first I tried adapting it to my project, which failed.
  Then I got frustrated and ended up creating a new project into which I just copy pasted the working code.</p>
  
  <p>And you guessed it, it doesn't work.</p>
  
  <p><a href="https://i.stack.imgur.com/dv2Q2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dv2Q2.png" alt="not working"></a></p>
  
  <p>Now I've tried quite a bit of stuff, I've changed my program from unicode to ansi and back, and done <code>mode = DISABLE_NEWLINE_AUTO_RETURN | ENABLE_VIRTUAL_TERMINAL_PROCESSING</code>, <code>mode |= DISABLE_NEWLINE_AUTO_RETURN | ENABLE_VIRTUAL_TERMINAL_PROCESSING</code>, and each individually with and without <code>|</code>with no success.</p>
  
  <p>Given it's error 87 which means bad parameter, I even tried putting the exact value from GetConsoleMode to see if it was the handle, but since it worked we can assume it's not the handle's problem.</p>
  
  <p>Basically code that works on another machine doesn't work on mine.
  The other machine was windows 10 mine's 8.1 both 64.</p>
  
  <p>On both machines the value gotten off GetConsoleMode the first time is 3, which means ENABLE_PROCESSED_OUTPUT and ENABLE_WRAP_AT_EOL_OUTPUT.</p>
  
  <p>The windows SDK version on my project is 10.0.15063.0, with a platform toolset of Visual Studio 2017 (v141).</p>
  
  <p>I've been at this all day with no success. Now it wouldn't be the first time I read over some important detail, but I've been going through documentation and nothing mentions the failiure of SetConsoleMode using ENABLE_VIRTUAL_TERMINAL_PROCESSING.</p>
  
  <p>As far as I can tell I'm doing it correctly based on the <a href="https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences" rel="noreferrer">Docs</a>
  <a href="https://i.stack.imgur.com/nL6lE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nL6lE.png" alt="docs"></a></p>
  
  <p>What should I be doing that I am not?</p>
  
  <p>Sorry for any spelling/grammar mistakes that might have gone noticed and thank you for your time.</p>