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. Opening a console window from a Windows form project

Opening a console window from a Windows form project

Scheduled Pinned Locked Moved C / C++ / MFC
questionwinformstutorial
5 Posts 3 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.
  • K Offline
    K Offline
    kialmur
    wrote on last edited by
    #1

    Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project? For example, I have a typical GUI interface and would like the option to use a command line interface instead. Using cout/cin does not work because there is no console window to output to or input from. How do I open this window without having to create a completely separate Win32 Console application? kialmur

    D 1 Reply Last reply
    0
    • K kialmur

      Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project? For example, I have a typical GUI interface and would like the option to use a command line interface instead. Using cout/cin does not work because there is no console window to output to or input from. How do I open this window without having to create a completely separate Win32 Console application? kialmur

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      kialmur wrote:

      Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project?

      Certainly. See here and here.


      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

      "Judge not by the eye but by the heart." - Native American Proverb

      K 1 Reply Last reply
      0
      • D David Crow

        kialmur wrote:

        Is there anyway to open a console window, where cout/cin can be used, from within a a Windows forms project?

        Certainly. See here and here.


        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

        "Judge not by the eye but by the heart." - Native American Proverb

        K Offline
        K Offline
        kialmur
        wrote on last edited by
        #3

        Is there no way that I can just open a console and use cout/cin? No forms are open at this point. It seems like quite a complex process just to write to a console.

        Z D 2 Replies Last reply
        0
        • K kialmur

          Is there no way that I can just open a console and use cout/cin? No forms are open at this point. It seems like quite a complex process just to write to a console.

          Z Offline
          Z Offline
          Zac Howland
          wrote on last edited by
          #4

          When you create a windows app that has a WinMain entry point, there isn't an easy way to create a console. That said, if you want to go the other route (create a console app that spawns your window at some point), it isn't too difficult, but does require some work as far as setting up message loops and such. Basically, yes, you can have a window with a console. No, it isn't easy to set up.

          If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

          1 Reply Last reply
          0
          • K kialmur

            Is there no way that I can just open a console and use cout/cin? No forms are open at this point. It seems like quite a complex process just to write to a console.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            kialmur wrote:

            Is there no way that I can just open a console and use cout/cin?

            Sure, if you are creating a simple console application. However, since you have a GUI application, the rules change.

            kialmur wrote:

            seems like quite a complex process just to write to a console.

            So just wrap it all up into a nice little class, and whenever you want something to be displayed in a console window, instantiate your class, and invoke a few methods. You could even skip the class part, and just put it all in a function (or three). Just call the functions whenever you want something to be displayed in a console window.


            "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

            "Judge not by the eye but by the heart." - Native American Proverb

            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