1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C++ Console

Discussion in 'C++' started by parkp333, Mar 9, 2007.

  1. parkp333

    parkp333 New Member

    Joined:
    Feb 2, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    How can I intergrate a console in a Windows GUI application. A CMD type thing.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    What do you mean by integrate?
     
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    If you'd like to open a separate command window, just execute a system ("cmd.exe"); call. If you want to make your own command interpreter, write it, and replace "cmd.exe" with "myCommandInterpreter.exe" (or whatever you call it).
    Code:
    #include <windows.h>
    #include <process.h>
    #include "stdafx.h"
    
    extern "C" int system (char *cmd);
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
    	system ("cmd.exe");
    	return 0;
    }
    
     
  4. parkp333

    parkp333 New Member

    Joined:
    Feb 2, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Well you see I just want a console in my GUI program because I need this to do some winsock because yeh... Well please tell me how to make a console type thing inside a GUI program?? This is very important to me
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    No, I don't see. Do you see? Did you even read the response? Do you see that it opens a console (without writing the rest of your code, of course). If you don't want the system's console window, make your own window and write your own command interpreter.
     
  6. parkp333

    parkp333 New Member

    Joined:
    Feb 2, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Where can I find this stdafx.h header file? and does this make a console inside your GUI window?
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    .h file can do nothing apart from just having some function signatures and stdafx file just does absolutely nothing apart from including some more headers files.
     
  8. parkp333

    parkp333 New Member

    Joined:
    Feb 2, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    yeh but i wonder how can i make a text box be some batch file i have made can someone give me a tip?
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Still I could not get what you want to be doing?
     
  10. parkp333

    parkp333 New Member

    Joined:
    Feb 2, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    I have made this Batch File and I want a text box kind of thing (where user can input) to be related to a batch file... so that if in my batch file i have for example

    set hello=
    set /p hello=Command:

    well that "Command:" appears in the text box in the c++ program...
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    You put a textbox in your app and ask for the input from the user and save it in a batch file on some place in the local disk.
     
  12. parkp333

    parkp333 New Member

    Joined:
    Feb 2, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    no because actually this thing i want is to put some console c++ apllication into a text box... is that possible
     
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    I doubt that but may try this.

    Have a custom control on the Dialog and change the class of the control to ConsoleWindowClass
    see if that works for you.
     
  14. parkp333

    parkp333 New Member

    Joined:
    Feb 2, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Ok, yeh well that is not really my point, i want to link a console based program to a text box area inside my GUI window
     

Share This Page