CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Including console project in Windows form

    Hi!

    I've always programmed in C++ in console mode so I don't know very much about VC++,
    the point is that I'm trying to export my C++ console application to a Windows form (VC++) in order to have a GUI.

    The problem is that i don't know how to import my application in the windows form, I've spent some days searching info on the Internet but I haven't been able to solve my problem.

    The only information I've found is that i should create a class for my console application and
    call this class in the windows form, but i don't know how to call the class in the windows form and also i'm not sure if I should do it in that way (maybe I should create a .dll?)

    Thanks in advance.

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: Including console project in Windows form

    1. Create a project for a windows application.
    2. Write lines of code for the GUI part.
    3. Insert a line:
    Code:
    system("c:\\dir_1\\my_console_app.exe")

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Including console project in Windows form

    Why bother ?

    your program seems to be working fine in console mode now. Noting wrong with that.

    If all your GUI application ends up doing is just simulating a console type program you've just succedded in doing a lot of work to get a gob of extra code size that achieves essentially nothing.

    i'm not saying making a GUI program is necessarily a bad thing, if you havea lot of input, or could benefit from feaures like built in configuration dialogs instead of using commandline parameters etc... then maybe, but turning a console program into a fully functional takes more than just wrapping all the code into a GUI.

    For one, a Console program is always responsive, this isn't the case for GUI, you'll likely need to create a worker thread for the work, and have your GUI thread respond to and submit work to that worker thread. Stuff like this can very easily turn a 100lines of console program into several thousand lines of GUI program for very little (if any) actual benefit.

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Including console project in Windows form

    your program seems to be working fine in console mode now. Noting wrong with that.
    Because it's fun ?

    Simply create a GUI project and move the essential code from your console application to your GUI application.

  5. #5
    Join Date
    Jan 2010
    Posts
    2

    Re: Including console project in Windows form

    @olivthill2: thanks for the help, but I don't want to execute the .exe file, i want to access to the functions and modify some variables for my console project, but using a GUI. I hope I'm explaining well :S

    @OReubens & @Skizmo: I know that there will be a lot of more work to do if I do it in windows form, but the main idea is this (I think I didn't explain it very well):

    - I have the console project with the functions, variables and all this stuff, so what I would like to do is exporting this to a Windows form, for example: - show the results in the windows form, - use some functions from the console app, - be able to have access to different variables in the windows form... and this stuff.

    That's why I thought that I should create a class for my console project, and call the functions and all the things I explained before, in the Windows form.

    The problem is that i don't know if a class is what I should do and if so, how I have to do it.

    Thanks in advance again,

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured