Announcement

Collapse
No announcement yet.

Windows 10 console-resize quirk

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Windows 10 console-resize quirk

    This probably isn't an issue for most PB/CC programmers. One of my customers is using code that calculates the screen size and then resizes the console to fill the screen, and he came across this...

    It appears that Windows 10 (or perhaps Windows 8+) doesn't always resize the console window exactly as requested. I've tested this with the PB/CC CON.SCREEN statement, with Console Tools, and with direct console-API calls, and Windows just won't cooperate. For example, if you attempt to use an odd number for the screen/buffer size, Windows will consistently round the number up or down by one. A request for 87 rows produces a console with either 86 or 88 rows. In some cases -- I haven't figured out the pattern -- it appears to round up to the next multiple of 10.

    Mostly just noting it for posterity.
    "Not my circus, not my monkeys."

  • #2
    Have a look at this Eric

    https://blogs.windows.com/buildingap...nical-preview/

    It might show you how but, if not, there's what looks like a "plan B" i.e.

    "Many applications have come to depend upon the current console functionality. If you discover an application that isn’t compatible with our additions, don’t worry. You can switch back to the old console host very easily. Later in this post, I’ll describe how to enable or disable new behavior selectively or all at once."

    Comment


    • #3
      Thanks Dean!
      "Not my circus, not my monkeys."

      Comment


      • #4
        You're welcome....Hope it solves your problem.

        Comment


        • #5
          Eric or Dean - could you please provide actual code that I can stick in my PBCC/Contools/GFX program that will disable the new Console functionality that might be messing up my program? I'm an engineer who does programming, not a computer systems guy, and I don't speak WinAPI except for careful copying of working wrappers!

          Comment


          • #6
            could you please provide actual code that I can stick in my PBCC/Contools/GFX program that will disable the new Console functionality...
            On the linked page (from Post #2), the following text is provided:

            Enable / Disable via the registry These features can also be toggled on/off via registry settings as shown below:
            [HKEY_CURRENT_USERConsole] all DWORD values

            Read more at https://blogs.windows.com/buildingap...ORApwoKk0Cb.99
            ....
            One if the settings there (text not shown) is "ForceV2 '1 for new console features, 0 to disable new console.'"

            That's not really all that explanatory to an engineer (more later on this) so.....

            You need to call the Windows' API function "RegSetValueEx" ...
            Code:
            LONG RegSetValueEx
              ( HKEY hKey  , 
               LPCTSTR lpValueName,
               DWORD Reserved,
               DWORD dwType, 
            const BYTE* lpData, 
               DWORD cbData);
            ... with
            HKEY = %HKEY_CURRENT_USER
            lpValueName = "ForceV2"
            reserved = BYVAL %NULL
            dwType = %REG_DWORD
            lpdata = VARPTR (LONG variable with value = 0&)
            cbData = 4&

            On return, you test for %ERROR_SUCCESS (= success) or some other value (=failed)

            There are multiple examples here; I suggest you 'search' the source code section for RegSetValueEx or maybe %HKEY_CURRENT_USER if you want more precise PB-syntax.

            I only went this far for the task of "set a registry value" because you said you are an engineer rather than a programmer. Had you claimed to be a programmer I would likely have just suggested you carefully Read The Friendly Manual, as "get or set a registry value" is a fundamental skill for a programmer.

            ("Calling an external function" is a fundamental skill for anyone authorized to click run/compile in the PB IDE; and if you are using Console Tools, you are already doing that)


            MCM

            Comment


            • #7
              Thanks Michael. I'll copy that code and give it a try.

              But, the "F" in RTFM means "Friendly?" I always thought it meant.....

              Comment


              • #8
                If in context it didn't mean "friendly" I would not have been quite so polite.

                On the engineer thing... a number of years ago I started a "poll" question here asking if members were full-time professional programmers, part-time professional programmers, or hobbyists. Let me see if I can find that.. well, how about that, searching for "poll" in the thread title found it... https://forum.powerbasic.com/forum/u...write-programs

                If you visit the link, you'll see I then (October 2007) had a very narrow view of the membership.

                What I learned from the responses was, we have a number of of members who program in support of their "real" jobs - as engineers, technicians or managers. That is, not professional programmers, but professional "something else" who used programming to aid them with the "something else." At the time, it was a revelation to me that there were seemingly so many in this classification..... and it also means you are not alone.

                Comment


                • #9


                  And thanks again!

                  Comment


                  • #10
                    It appears that Windows 10 (or perhaps Windows 8+) doesn't always resize the console window exactly as requested.
                    Not exactly unique within Windows.

                    CreateFont() will not always create exactly what was requested ...
                    nWidth [in] Specifies the average width, in logical units, of characters in the requested font. If this value is zero, the font mapper chooses a closest match value. The closest match value is determined by comparing the absolute values of the difference between the current device's aspect ratio and the digitized aspect ratio of available fonts. ......

                    To help protect the copyrights of vendors who provide fonts for Windows, applications should always report the exact name of a selected font. Because available fonts can vary from system to system, do not assume that the selected font is always the same as the requested font. For example, if you request a font named Palatino, but no such font is available on the system, the font mapper will substitute a font that has similar attributes but a different name. Always report the name of the selected font to the user.

                    Comment

                    Working...
                    X