Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Console Window

Console Window

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Daniel1324
    wrote on last edited by
    #1

    Right now, I'm using #pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"") to keep the console window from being shown. However, later in the program, I want to show the window for text input and output. I've tried CreateConsoleScreenBuffer() and all but cant figure out how to do this. By using the pragma, am I preventing the window from ever being shown? If not, how do I show the console window?

    D 1 Reply Last reply
    0
    • D Daniel1324

      Right now, I'm using #pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"") to keep the console window from being shown. However, later in the program, I want to show the window for text input and output. I've tried CreateConsoleScreenBuffer() and all but cant figure out how to do this. By using the pragma, am I preventing the window from ever being shown? If not, how do I show the console window?

      D Offline
      D Offline
      Dominik Reichl
      wrote on last edited by
      #2

      Can't you just use AllocConsole and FreeConsole ? Best regards, Dominik


      _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

      D 1 Reply Last reply
      0
      • D Dominik Reichl

        Can't you just use AllocConsole and FreeConsole ? Best regards, Dominik


        _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

        D Offline
        D Offline
        Daniel1324
        wrote on last edited by
        #3

        Thanks for the reply. AllocConsole() creates a new console window, but I cant print anything to it using printf or cout. As you can see, I'm not very good with win32 console programming. Any suggestions? Thanks!

        D 1 Reply Last reply
        0
        • D Daniel1324

          Thanks for the reply. AllocConsole() creates a new console window, but I cant print anything to it using printf or cout. As you can see, I'm not very good with win32 console programming. Any suggestions? Thanks!

          D Offline
          D Offline
          Dominik Reichl
          wrote on last edited by
          #4

          I'm not that expert with console programming too but you can try these 2 ways: 1) use the Windows functions for console writing: get a handle to the current console using the GetStdHandle function. Then use the WriteConsole function to write to it. 2) there is a way to use the freopen function and redirect all printf commands (stdout/stdin/stderr) to your new console window. You must somehow get a FILE* for the console, but don't ask me how to do this... Best regards, Dominik


          _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

          D 1 Reply Last reply
          0
          • D Dominik Reichl

            I'm not that expert with console programming too but you can try these 2 ways: 1) use the Windows functions for console writing: get a handle to the current console using the GetStdHandle function. Then use the WriteConsole function to write to it. 2) there is a way to use the freopen function and redirect all printf commands (stdout/stdin/stderr) to your new console window. You must somehow get a FILE* for the console, but don't ask me how to do this... Best regards, Dominik


            _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

            D Offline
            D Offline
            Daniel1324
            wrote on last edited by
            #5

            Thanks!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups