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 in Windows

Console window in Windows

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++debugging
7 Posts 5 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.
  • I Offline
    I Offline
    Iceberg76
    wrote on last edited by
    #1

    Hello, I have created a Win32 Windows application that uses a WinMain() and WndProc(). Currently, my application runs within the application Window. I want to see the output of variables, but not inside my application window. Instead, I want to use the console window. Basically, I want to run my application and then if the programs debug flag is on then I want to open up a console window and start printing variables. How do I do this, because if I choose a console application there is no WinMain? In addition, how do I call an .exe from within my Win32 windows program. Like the cmd.exe and then another custom.exe within that console window? I do not wish to use MFC at this time. Thanks.

    U F A 3 Replies Last reply
    0
    • I Iceberg76

      Hello, I have created a Win32 Windows application that uses a WinMain() and WndProc(). Currently, my application runs within the application Window. I want to see the output of variables, but not inside my application window. Instead, I want to use the console window. Basically, I want to run my application and then if the programs debug flag is on then I want to open up a console window and start printing variables. How do I do this, because if I choose a console application there is no WinMain? In addition, how do I call an .exe from within my Win32 windows program. Like the cmd.exe and then another custom.exe within that console window? I do not wish to use MFC at this time. Thanks.

      U Offline
      U Offline
      User 1057324
      wrote on last edited by
      #2

      its better if u go for a console based application. why do u need WinMain- its better to use main(). but, if u need a win32 application, then u have to start a win32 application project. i u wish to see the current values of various variables, add a listbox and print then all... but, i suggest to use the DEBUGGING procedures inside the IDE... use Ctrl-F10 for running to cursor, etc... u can set WATCHES, etc.... for calling an EXE from inside ur win32 application, use the WinExec or ShellExecute API... or u can go for the CreateProcess API... my suggestion is to use the ShellExecute API.. its very simple and powerfull... one more thing, its better not to use MFC , if ur more into SYstem Side Programming.....

      I 1 Reply Last reply
      0
      • U User 1057324

        its better if u go for a console based application. why do u need WinMain- its better to use main(). but, if u need a win32 application, then u have to start a win32 application project. i u wish to see the current values of various variables, add a listbox and print then all... but, i suggest to use the DEBUGGING procedures inside the IDE... use Ctrl-F10 for running to cursor, etc... u can set WATCHES, etc.... for calling an EXE from inside ur win32 application, use the WinExec or ShellExecute API... or u can go for the CreateProcess API... my suggestion is to use the ShellExecute API.. its very simple and powerfull... one more thing, its better not to use MFC , if ur more into SYstem Side Programming.....

        I Offline
        I Offline
        Iceberg76
        wrote on last edited by
        #3

        Thanks for the response. I will look at ShellExecute. I need to create a win32 window for my graphics application. Can I still create a window with a console application. Currently I am using winmain, but I want to simultaneously launch a console. How do I do this? Can I use a console based application with a main and then create a win32 window? Thanks

        _ U 2 Replies Last reply
        0
        • I Iceberg76

          Thanks for the response. I will look at ShellExecute. I need to create a win32 window for my graphics application. Can I still create a window with a console application. Currently I am using winmain, but I want to simultaneously launch a console. How do I do this? Can I use a console based application with a main and then create a win32 window? Thanks

          _ Offline
          _ Offline
          _foo
          wrote on last edited by
          #4

          You can use the AllocConsole() API to create a console for your application

          1 Reply Last reply
          0
          • I Iceberg76

            Thanks for the response. I will look at ShellExecute. I need to create a win32 window for my graphics application. Can I still create a window with a console application. Currently I am using winmain, but I want to simultaneously launch a console. How do I do this? Can I use a console based application with a main and then create a win32 window? Thanks

            U Offline
            U Offline
            User 1057324
            wrote on last edited by
            #5

            nope, u cannot use the console based application project and then create a win32 application... i guess u can, but u will have to change the compiler setting and other linker options.... some other person gave u a reply on using allocconsole() api, go for that, search it in MSDN... or google it....

            1 Reply Last reply
            0
            • I Iceberg76

              Hello, I have created a Win32 Windows application that uses a WinMain() and WndProc(). Currently, my application runs within the application Window. I want to see the output of variables, but not inside my application window. Instead, I want to use the console window. Basically, I want to run my application and then if the programs debug flag is on then I want to open up a console window and start printing variables. How do I do this, because if I choose a console application there is no WinMain? In addition, how do I call an .exe from within my Win32 windows program. Like the cmd.exe and then another custom.exe within that console window? I do not wish to use MFC at this time. Thanks.

              F Offline
              F Offline
              FirstPerson
              wrote on last edited by
              #6

              i think the TRACE(...) may be what you want; used like printf, and output to the IDE's output-window only when debugging; hope this helps ;)

              1 Reply Last reply
              0
              • I Iceberg76

                Hello, I have created a Win32 Windows application that uses a WinMain() and WndProc(). Currently, my application runs within the application Window. I want to see the output of variables, but not inside my application window. Instead, I want to use the console window. Basically, I want to run my application and then if the programs debug flag is on then I want to open up a console window and start printing variables. How do I do this, because if I choose a console application there is no WinMain? In addition, how do I call an .exe from within my Win32 windows program. Like the cmd.exe and then another custom.exe within that console window? I do not wish to use MFC at this time. Thanks.

                A Offline
                A Offline
                Anthony_Yio
                wrote on last edited by
                #7

                check out debugview from sysinternals.com Sonork 100.41263:Anthony_Yio Life is about experiencing ...

                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