The new console mode disaster
Posted: 07 Aug 2017 07:14
It was reported by penpen that "setfont" operation of my program "cmdwiz" did not work on Windows 10 machines.
Since I am a dinosaur I don't have a Win10 machine but I recently got ahold of one and tried it. As expected, my program did not work. I then found a setting in the cmd window properties called "Use legacy console (requires relaunch)". When I clicked this and restarted the cmd window, lo and behold, "cmdwiz setfont" worked just fine to change fonts.
Ok, so apparently Microsoft introduced "new console features" that break the old API's. Great. It's documented here: https://technet.microsoft.com/en-us/library/mt427362(v=ws.11).aspx
Then I tried carlos "bg" program, which reportedly works in Windows10. I tried it, and found that while it seemed to "kind of" work, it was acting strange. For example, there was no difference whatsoever between font 1 and font 2, and no difference between font 5 and font 6. Also, I had indication that the fonts were not the right sizes! Which turned out to be true.
It's actually easy to see this. Set e.g. font 0 or font 1 using carlos tool: "bg font 0". Type "start" to get a new window with a font of the same size. Now change the console mode to legacy mode in the properties, and type "start" again. The font is now much smaller. (It is, actually, the size in pixels it is supposed to be according to the properties settings!)
For my purposes, this is highly annoying. It means that even though we have set a font that is said to be 4x6 pixels (that is what it says in the setting properties for "raster font 0"), it is not! (when the new console mode is on).
Anyway, can I not just set this legacy mode then? Well, we can enable or disable the legacy console using this line (0 for legacy console, 1 for new console mode):
But...
1. The change is not immediate. Only when you open a new cmd window, the change will be visible
2. I think the current user would have to have admin privileges to set this (?)
3. If used in a script, it's tricky to restore the previous setting at the end of the script. What if the user just closes the window?
Anybody with more insights?
(my specific problem related to this is that for my program cmdgfx_gdi, I need to set an exact width and height for the window. To get e.g a 400x600 window, I would set the font to raster font 0 (it's 4x6 pixels), then do "mode 100,100". But obviously, if the size of the font cannot be trusted, then this method cannot be trusted (and all my windows end up being too big on Win10 if console legacy mode is not enabled! ... Oh my... I should have listened to aGerman, GUI stuff in the cmd window is just silly )
Since I am a dinosaur I don't have a Win10 machine but I recently got ahold of one and tried it. As expected, my program did not work. I then found a setting in the cmd window properties called "Use legacy console (requires relaunch)". When I clicked this and restarted the cmd window, lo and behold, "cmdwiz setfont" worked just fine to change fonts.
Ok, so apparently Microsoft introduced "new console features" that break the old API's. Great. It's documented here: https://technet.microsoft.com/en-us/library/mt427362(v=ws.11).aspx
Then I tried carlos "bg" program, which reportedly works in Windows10. I tried it, and found that while it seemed to "kind of" work, it was acting strange. For example, there was no difference whatsoever between font 1 and font 2, and no difference between font 5 and font 6. Also, I had indication that the fonts were not the right sizes! Which turned out to be true.
It's actually easy to see this. Set e.g. font 0 or font 1 using carlos tool: "bg font 0". Type "start" to get a new window with a font of the same size. Now change the console mode to legacy mode in the properties, and type "start" again. The font is now much smaller. (It is, actually, the size in pixels it is supposed to be according to the properties settings!)
For my purposes, this is highly annoying. It means that even though we have set a font that is said to be 4x6 pixels (that is what it says in the setting properties for "raster font 0"), it is not! (when the new console mode is on).
Anyway, can I not just set this legacy mode then? Well, we can enable or disable the legacy console using this line (0 for legacy console, 1 for new console mode):
Code: Select all
reg add HKCU\Console /v ForceV2 /t reg_dword /d 0x0 /f
But...
1. The change is not immediate. Only when you open a new cmd window, the change will be visible
2. I think the current user would have to have admin privileges to set this (?)
3. If used in a script, it's tricky to restore the previous setting at the end of the script. What if the user just closes the window?
Anybody with more insights?
(my specific problem related to this is that for my program cmdgfx_gdi, I need to set an exact width and height for the window. To get e.g a 400x600 window, I would set the font to raster font 0 (it's 4x6 pixels), then do "mode 100,100". But obviously, if the size of the font cannot be trusted, then this method cannot be trusted (and all my windows end up being too big on Win10 if console legacy mode is not enabled! ... Oh my... I should have listened to aGerman, GUI stuff in the cmd window is just silly )