Announcement

Collapse
No announcement yet.

Maximise Size of Visible Console Screen

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

  • Maximise Size of Visible Console Screen

    When I run an application on my oldish Compaq desktop computer the CONSOLE GET FOCUS does what I want and gives me a display which fills the physical screen. When I run the same application on a slightly newer Acer 5745 laptop the display fills only the top left quarter.of the physical screen. I can make it fill the whole screen by using the Windows maximise button, but how can I make sure that I always get a full size display without using the Windows maximise button? I've tried a wide variety of CONSOLE instructions (eg SCREEN, VIEW, , VIRTUAL, etc) without success.

  • #2
    ... that should of course read CONSOLE SET FOCUS, not GET. Apologies

    Comment


    • #3
      What versions of Windows on the two machines?
      --
      [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
      PNG Domain Hosting[/URL]

      Comment


      • #4
        Hi John,

        Try using a ShowWindow CONSHNDL, 3 statement as shown in this sample code.

        Regards,


        Code:
        #COMPILE EXE
        #DIM ALL
        #BREAK ON
        
        DECLARE FUNCTION ShowWindow LIB "USER32.DLL" ALIAS "ShowWindow" (BYVAL hWnd AS DWORD, BYVAL nCmdShow AS LONG) AS LONG
        DECLARE FUNCTION GetLargestConsoleWindowSize LIB "KERNEL32.DLL" ALIAS "GetLargestConsoleWindowSize" (BYVAL hConsoleOutput AS DWORD) AS DWORD
        DECLARE FUNCTION SetConsoleFont LIB "KERNEL32.DLL" ALIAS "SetConsoleFont"(BYVAL hConsole AS DWORD, BYVAL dwIndex AS DWORD) AS LONG
        
        
        FUNCTION PBMAIN () AS LONG
         LOCAL CB???
         LOCAL MaxRows, MaxCols AS WORD
         LOCAL ClientSize AS DWORD
         LOCAL ROWS&,COLUMNS&, R&, RH&, I&, J&
         LOCAL FG%,BG%
        
         CB??? = SetConsoleFont(GETSTDOUT, 12)     'Font Index 0 to 21
         ClientSize = GetLargestConsoleWindowSize(GETSTDOUT)
         MaxRows = HI(WORD,ClientSize)-1
         MaxCols = LO(WORD,ClientSize)-1
         R&=MaxRows-1
         RH&=MaxCols
         DESKTOP GET CLIENT TO I, J
         CONSOLE SET SCREEN R&, RH&
         ShowWindow CONSHNDL, 3
         DESKTOP GET CLIENT TO I&,J&
         CONSOLE SET LOC (I&-CON.SIZE.X)\2,(J&-CON.SIZE.Y)\2 'Centered in the client's desktop
        
         'Customize
         FG%=7         'Can change the foreground and background colors
         BG%=1
         COLOR FG%,BG%
         CLS
         LOCATE 1,1
         PRINT CON.SIZE.X,CON.SIZE.Y, I&,J&
         WAITKEY$
        END FUNCTION

        Comment


        • #5
          Stuart - both computers use Windows 7
          Manuel - thanks. I wasn't aware of CONSHNDL. I'll try it and see
          .

          Comment


          • #6
            Hi Manuel,
            The statement ShowWindow CONSHNDL, 3 does the job, but I don't understand why. I also tried ShowWindow CONSHNDL, SW_MAXIMIZE but that made the console window disappear leaving the underlying but unresponsive graphics window. I could only shut the application down by shutting down the computer.. Can you tell me how you discovered you should use 3 and not SW_MAXIMIZE ?

            Comment


            • #7
              ???
              %SW_MAXIMIZE = 3 , did you use % in your source (not shown)((but then you'd have compile time error, not run time failure)). Using equate %SW_MAXIMIZE or literal 3 in code should make no difference.
              https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

              CONSHNDL is legacy, see Help for PBCC version you use.
              In PBCC 6 current syntax is - CON.HANDLE TO variable&

              John, code that compiles and demonstrates error (not neccessarily your whole program) helps others help you.

              Cheers,
              Dale

              Comment


              • #8
                Originally posted by John Moorby View Post
                Hi Manuel,
                The statement ShowWindow CONSHNDL, 3 does the job, but I don't understand why. I also tried ShowWindow CONSHNDL, SW_MAXIMIZE but that made the console window disappear leaving the underlying but unresponsive graphics window. I could only shut the application down by shutting down the computer.. Can you tell me how you discovered you should use 3 and not SW_MAXIMIZE ?
                Just a WAG, but do you use #DIM ALL

                If not, SW_MAXIMIZE (without the %) may have been treated as an uninitialised integer of value 0.

                So that would be the equivalent of ShowWindow CONSHNDL, 0 or ShowWindow CONSHNDL %SW_HIDE.
                --
                [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                PNG Domain Hosting[/URL]

                Comment


                • #9
                  Just a WAG, but do you use #DIM ALL
                  Concur. Make it "EWAG"!

                  Still more reason to show failing code. Guessing would not be needed!

                  Cheers,
                  Dale

                  Comment


                  • #10
                    Hi John,

                    This link provides a good explanation of the ShowWindow function, and its parameters.

                    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx


                    IN PBCC you can also use this Built-in Equates, even though they are not documented in the PBCC Help but in the PBWIN's

                    %SW_HIDE, %SW_SHOWNORMAL, %SW_NORMAL, %SW_SHOWMINIMIZED, %SW_SHOWMAXIMIZED, %SW_MAXIMIZE, %SW_SHOWNOACTIVATE, %SW_SHOW, %SW_MINIMIZE, %SW_SHOWMINNOACTIVE, %SW_SHOWNA, %SW_RESTORE, %SW_SHOWDEFAULT, %SW_FORCEMINIMIZE, %SW_MAX

                    Please be aware that a PBCC console is an special case of a window, so only some of the parameters are functional.
                    I'm guessing that you are trying to alternate between a Console and one or more GRAPHIC WINDOWS. Are you aware that you can write complete and quite powerful applications within just a GRAPHIC WINDOW?

                    Regards,

                    Comment


                    • #11
                      Sadly I don't know what WAG means. I must get out more! You are teaching me a bit about programming, but may be I could offer you a little reactor physics. I would be happy to give each of you the whole .bas code (nearly 6000 lines, 258kB) if you are interested. Maybe you can make it run faster. Can I do that here?.

                      Comment


                      • #12
                        Sadly I don't know what WAG means.
                        That is the least important thing from above

                        It is simply an acronym for Wild A Guess (I'll let you guess what the A is for).

                        Adding E at the beginning makes it an Educated WAG (better chance of being correct).

                        Cheers and keep coding,
                        Dale

                        Comment


                        • #13
                          Originally posted by John Moorby View Post
                          Sadly I don't know what WAG means. I must get out more! You are teaching me a bit about programming, but may be I could offer you a little reactor physics. I would be happy to give each of you the whole .bas code (nearly 6000 lines, 258kB) if you are interested. Maybe you can make it run faster. Can I do that here?.
                          HI John, I've sent you a Private Message.
                          --
                          [URL="http://www.camcopng.com"]CAMCo - Applications Development & ICT Consultancy[/URL][URL="http://www.hostingpng.com"]
                          PNG Domain Hosting[/URL]

                          Comment


                          • #14
                            Hi John,

                            You are not alone, many members of this forums are technicians, engineers, scientists, scholars or professionals of different technical or scientific disciplines, who became programmers out of necessity to get the proper data processing tool, or the fittest to our own work or budget. Keep coding, keep asking for help.

                            Regards,

                            Comment


                            • #15
                              oldish Compaq
                              Redundant.
                              Michael Mattias
                              Tal Systems Inc.
                              Racine WI USA
                              mmattias@talsystems.com
                              http://www.talsystems.com

                              Comment

                              Working...
                              X