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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC dialog based application and command prompt

MFC dialog based application and command prompt

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 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.
  • R Offline
    R Offline
    Rostfrei
    wrote on last edited by
    #1

    Hello! I searched all over the net for the following solution. I have some MFC dialog based application. I still want to use printf, cout, etc., but there is no console window, just dialog. Is there some way to use stdout the same way like in command prompt programs? I found one way of doing this: AllocConsole(); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),(void *)out,(DWORD)strlen(out),&written,0); but the problem here is that you have to use WriteFile function and cout or printf does not work. Best regards, Rostfrei

    U 1 Reply Last reply
    0
    • R Rostfrei

      Hello! I searched all over the net for the following solution. I have some MFC dialog based application. I still want to use printf, cout, etc., but there is no console window, just dialog. Is there some way to use stdout the same way like in command prompt programs? I found one way of doing this: AllocConsole(); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),(void *)out,(DWORD)strlen(out),&written,0); but the problem here is that you have to use WriteFile function and cout or printf does not work. Best regards, Rostfrei

      U Offline
      U Offline
      uus99
      wrote on last edited by
      #2

      You can show a console, by adding the following line in Post-Build in Project Properties (VC2003) or Project Settings Post-Build Step (VC6). editbin /SUBSYSTEM:CONSOLE "$(OUTDIR)"\ Where program name is the name of your final build exe. If i am building Notepad.exe, then it would be editbin /SUBSYSTEM:CONSOLE "$(OUTDIR)"\notepad.exe You can also call it from cmd.exe manually editbin /SUBSYSTEM:CONSOLE c:\programfiles\etc\etc\notepad.exe Usman

      R 1 Reply Last reply
      0
      • U uus99

        You can show a console, by adding the following line in Post-Build in Project Properties (VC2003) or Project Settings Post-Build Step (VC6). editbin /SUBSYSTEM:CONSOLE "$(OUTDIR)"\ Where program name is the name of your final build exe. If i am building Notepad.exe, then it would be editbin /SUBSYSTEM:CONSOLE "$(OUTDIR)"\notepad.exe You can also call it from cmd.exe manually editbin /SUBSYSTEM:CONSOLE c:\programfiles\etc\etc\notepad.exe Usman

        R Offline
        R Offline
        Rostfrei
        wrote on last edited by
        #3

        Thank you very much. That is exactly what I needed. Best regards, Rostfrei

        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