Announcement

Collapse
No announcement yet.

#console Off

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

  • #console Off

    I compile my program with #COMPILE OFF option.

    How can I activate and show the windows cosole at the run time?

    Thanks.

  • #2
    You can TRY the WinApi function AllocConsole() to create a console for the currently-executing program and make it the default STDIN/STDOUT/STDERROR.

    I say "try" because I don't know that the PB/CC compiler will treat a "foreign" console the same as it treats a console created when the program is compiled with #CONSOLE ON.

    I do know that at least thru version 3x of the compiler, PB/CC programs did not respect a change to the standard handles during execution (using SetStdHandle function), but that may have been addressed in 4x. (I have not tested with my 4x PB/CC).

    But this is pretty easy to try.

    The simpler answer is, of course, is to compile the program with #CONSOLE ON. I don't understand why you wouldn't just do this.
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Because..

      When I launch my program in "normal way", I want that NOTHING appear
      on the screen but I want the possibility to open the console when the program is already running, for a diagnostic scope, and after that, put the console away.
      I'm sorry, may be easy, but is for me the first time with PBCC...

      In any case, I'll try your solution.
      Thanx

      Comment


      • #4
        You could try this in your WinMain function somewhere

        Code:
         LOCAL waiting AS STRING
          CONSOLE SET LOC 50,50
          waiting=WAITKEY$
          CONSOLE SET LOC 1600,50
          waiting=WAITKEY$
          CONSOLE SET LOC 50,50
        It will position the console outside the view area if nothing else works for you.

        Rod
        Rod
        I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

        Comment


        • #5
          Turn Console Off, and On again

          I recently did something similar in PBCC 4.04.

          If the console is turned off with #Console Off, a new console window may be created with AllocConsole, but PBCC does not recognize this window, and cannot print to it. I could not find a way to inform PBCC about the new console window.

          However, if the #Console Off option is omitted and the console is turned off with FreeConsole instead, it may be turned on and off at will and remains functioning.

          Arie Verheul

          Comment


          • #6
            Well done!

            Rod
            Rod
            I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

            Comment


            • #7
              Code:
              
              
              #INCLUDE "C:\PBcc40\WinAPI\win32api.inc"
              
              hConsole = CONSHNDL
              
              ShowWindow hConsole, %SW_Hide 'if you want to turn off the console
              
              ShowWindow hConsole, %SW_Show 'if you want to turn it back on.
              Last edited by Jerry Fielden; 11 Apr 2008, 03:43 PM.

              Comment


              • #8
                Tht's correct, the console is just another window, so a simple call to ShowWindow can toggle the visibility state. Also, toggling the visibility state has the additional benefit of keeping what text is in the console.
                kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                Comment


                • #9
                  On top of what others have suggested, using a Shortcut to start your program can make the initial console less annoying. Tell the shortcut to start the program as Minimized, then use ShowWindow HIDE early in your program, and all you'll see is the momentary flash of a button on the Task Bar. The console window won't actually become visible for even a split second.

                  Then again if you want a lot of control, my company's Console Tools product includes a utility program that can launch a console program in a hidden console, and lots of other cool stuff... Click on the first link below.

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

                  Comment

                  Working...
                  X