Announcement

Collapse
No announcement yet.

Need help with Console Set Screen and Console Tools

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

  • Need help with Console Set Screen and Console Tools

    Hi,
    Years ago I had a pgm compiled in PBCC30. I used Console tools CWC to set console window font to non-standard 9x16 custom raster font then would launch my pgm which used the CONSOLE SCREEN to 34,88 (this was manually calculated fill the screen with no scroll bars with desktop res 800x600) this worked perfectly. Console window started maximized and had no scroll bars. Since then PBCC40 (except 4.03) and PBCC50 replacement command CONSOLE SET SCREEN does not work the same (again except ver 4.03 worked) What is happening with the CONSOLE SET SCREEN is that the console window is not displaying Maximized - therefore scroll bars are added - if manually click on the Maximized console window button, console window is then as should be 34,88. I have researched extensivly the forums for a workaround and have tried the %SW_MAXIMIZED api call with no luck. I dont know if this is a PB or Console tools issue. I do know that everything worked perfect with the PBCC3 CONSOLE SCREEN.
    Thanks in advance for any help with this,
    Mary

  • #2
    instead of CWC have you tried using
    hConsole = ConsHndl
    ShowWindow hConsole, %SW_MAXIMIZE

    (with the appropriate Console Screen statement)
    or in addition to CWC so that you can use your raster font.
    Last edited by Fred Buffington; 23 Apr 2009, 06:03 PM.
    Client Writeup for the CPA

    buffs.proboards2.com

    Links Page

    Comment


    • #3
      Mary --

      It sounds like you are using the CWC "wrapper" utility that is provided with Console Tools, but that your main program is not using Console Tools (the DLL) itself. Is that correct?

      In your CWC file, are you using WINSTATE: Maximized ?

      If you're not using the DLL, I'd expect Fred's code to work. But sometimes there are timing issues with the console window; it won't always respond to ShowWindow immediately after the use of certain other APIs, unless you SLEEP first.

      If you are using the Console Tools DLL in your main program, using ConsoleWindow %MAXIMIZE should fix the problem. It automatically performs the necessary delays.

      -- Eric Pearson, Perfect Sync, Inc.
      "Not my circus, not my monkeys."

      Comment


      • #4
        I have already tried what Fred has suggested, console window still not maximized (CWC wrapper Maximized setting also). I have also tried what what Eric suggested using the Console Tools dll as well, console window still
        not maximized. I just cant figure out why the pre pbcc4 console screen statement worked perfectly and now console set screen is not for window maximized. We have moved on with a different workaround but I am still curious as to how to get the console window to show maximized. There have been prior post with similar problem. Fred and Eric, Thanks very much for your suggestions and help. Have a Great Day

        Comment


        • #5
          I couldnt get ConsoleWindow %MAXIMIZE to work on WinME although the ShowWindow did.

          Mary, I know you will say yes to this but i'll ask it anyway; are you getting a value for hConsole (or whatever variable you use) ?

          ConsoleWindow %MAXIMIZE works with PBcc2 when using CWC but not with PBcc4.

          **Added Later**
          Since I don't use ConsoleTools+Graphics much anymore, I thought it worth mentioning that I do not have the latest
          version of contools or graphics from P.S. so my results may differ from others.
          Last edited by Fred Buffington; 28 Apr 2009, 07:03 PM.
          Client Writeup for the CPA

          buffs.proboards2.com

          Links Page

          Comment


          • #6
            The pigheaded console

            I usually manage to let the console do what i need it to do, but i know that Windows may be very pigheaded about console settings. The problem is that once such an issue is solved one does not remember what the problem was.
            As i am not sure what the exact problem is, or what exactly you want to achieve, i simply listed some things that might be relevant:

            Apart from setting the console size with Console Set Screen, it may be a good idea to always explicitly set the buffer size with Console Set Virtual.
            The general rule is that scroll bars will be installed if both the Rows and Columns settings for the buffer size exceed those of the screen.

            The WinApi function GetLargestConsoleWindowSize retrieves the maximum number of rows and columns that will fit on the full screen.

            If you want the console to occupy the full screen, it is usually needed to use the WinApi function ShowWindow.
            However with Vista this is different.

            If you want the console to occupy a given area on the screen (in pixels), then it is possible to set the console size with the WinApi function SetWindowPos.

            When searching MSDN i found that there is a WinApi function SetConsoleFont, which is only implemented in Vista.
            As i do not use Vista i could never try this, but for Vista users it might be useful.

            I once needed a console that adjusted itself to the actual content, and i added that code below, just in case it might be useful.


            Arie Verheul


            Code:
             
            #Compile Exe
            #Dim All
            #Break On
             
            %ConsoleWidth         = 120      ' Size of virtual console
            %ConsoleHeight        = 100
            %DefaultConsRows      = 10       ' Minimum console size
             
            %HWND_TOPMOST    = &HFFFFFFFF
            %SWP_SHOWWINDOW  = &H0040
             
            Type COORD
              x As Integer
              y As Integer
            End Type
             
            Type CONSOLE_FONT_INFO
              nFont As Dword
              dwFontSize As Coord
            End Type
             
            '-----------------------------------------------------------------------------------
             
            Declare Function GetLargestConsoleWindowSize Lib "KERNEL32.DLL" _
                     Alias "GetLargestConsoleWindowSize" _
                     (ByVal hConsoleOutput As Dword) As Dword
             
            Declare Function SetWindowPos Lib "USER32.DLL" _
                     Alias "SetWindowPos" _
                     (ByVal hWnd As Dword,_
                      ByVal hWndInsertAfter As Dword,_
                      ByVal x As Long, ByVal y As Long,_
                      ByVal cx As Long, ByVal cy As Long,_
                      ByVal wFlags As Dword) As Long
             
            Declare Function GetCurrentConsoleFont Lib "kernel32.dll" _
                     Alias "GetCurrentConsoleFont" _
                    (ByVal hConsoleOutput As Long,_
                     ByVal bMaximumWindow As Long,_
                     lpConsoleCurrentFont As CONSOLE_FONT_INFO ) As Long
             
            Declare Function GetConsoleFontSize Lib "kernel32.dll" _
                     Alias "GetConsoleFontSize" _
                    (ByVal hConsoleOutput As Long, ByVal nFont As Long) As Dword
             
            '-----------------------------------------------------------------------------------
             
            Sub ConsoleScreen
             
                Local WindowSize     As Dword
                Local MaxRows, MaxCols  As Word
                Local ConsX,ConsY    As Long
                Local ConsWidth,ConsHeight As Long
                Local ClientWidth,ClientHeight As Long
             
                WindowSize = GetLargestConsoleWindowSize (GetStdOut)
             
                MaxRows    = (Hi(Word, WindowSize))
                MaxCols    = (Lo(Word, WindowSize))
             
                Console Set Screen  %DefaultConsRows,MaxCols
             
                Console Set Virtual %ConsoleHeight,%ConsoleWidth
             
                Desktop Get Client To ClientWidth,ClientHeight
                Desktop Get Loc    To ConsX,ConsY
                Console Get Size   To ConsWidth,ConsHeight
             
                ConsX = ConsX + (ClientWidth - ConsWidth)\2
                ConsY = ConsY - 5
             
                SetWindowPos(ConsHndl,%HWND_TOPMOST,ConsX,ConsY,ClientWidth,ConsHeight,%SWP_SHOWWINDOW)
             
                Cursor Off
                Mouse 3
                Mouse On
             
            End Sub
             
            '-----------------------------------------------------------------------------------
             
            Sub AdjustConsole (DesiredRows As Long)
             
                ' Adjusts console size to actual needs
             
                Dim   FontData                   As CONSOLE_FONT_INFO
                Local ConsX,ConsY,FontHeight     As Long
                Local ConsWidth,ConsHeight       As Long    ' Size in pixels
                Local CurrentRows,CurrentCols    As Long    ' Size in Rows/Columns
                Local ClientWidth,ClientHeight   As Long    ' Desktop client size
             
                ' Collect info about current situation
             
                Console Get Loc    To ConsX,ConsY
                Console Get Size   To ConsWidth,ConsHeight
                Console Get Screen To CurrentRows,CurrentCols
                Desktop Get Client To ClientWidth,ClientHeight
             
                ' Determine height of console font
                ' Both functions below are not in (my copy of) the WinApi includes
             
                GetCurrentConsoleFont(GetStdOut, 0, ByVal VarPtr(FontData))
                FontHeight = Hi(Word,GetConsoleFontSize(GetStdOut, FontData.nFont))
             
                ' Calculate the difference with the current size to avoid frame overhead issues
             
                DesiredRows = Max&(DesiredRows, %DefaultConsRows)
             
                ConsHeight  = ConsHeight + FontHeight * (DesiredRows - CurrentRows)
             
                ConsHeight  = Min&(ConsHeight, ClientHeight - ConsY)   ' Keep scrollbars on the screen
                ConsWidth   = Min&(ConsWidth,  ClientWidth  - ConsX)
             
                SetWindowPos(ConsHndl,%HWND_TOPMOST,ConsX,ConsY,ConsWidth,ConsHeight,%SWP_SHOWWINDOW)
             
            End Sub
             
            '-----------------------------------------------------------------------------------
             
            Function PBMain () As Long
             
                Local I     As Long
                Local X,Y   As Long
             
                ConsoleScreen
             
                For I = 1 To 20
                    Print "LINE  ";I
                    Console Set View 1,1
                    If I > %DefaultConsRows Then AdjustConsole I
                    Sleep 500
                Next
             
              WaitKey$
             
            End Function

            Comment


            • #7
              Originally posted by Fred Buffington View Post
              ConsoleWindow %MAXIMIZE works with PBcc2 when using CWC but not with PBcc4.
              ConsoleWindow %MAXIMIZE also worked with PBcc3 when using CWC but not with PBcc4 or PBcc5

              Comment


              • #8
                Thanks Arie, I will give your code a try

                Comment


                • #9
                  Mary,

                  If Arie code does not work, try my Graphic Console technique.
                  It will work with all Windows flavors including Windows Seven.
                  Old QB45 Programmer

                  Comment

                  Working...
                  X