?
Solved

Toggle between Console/GUI mode

Posted on 2005-04-11
6
Medium Priority
?
241 Views
Last Modified: 2013-11-20
I have a MFC application.I would like to be able to toggle between the GUI mode and Console mode.I have
figured out how to open a Console,but now when I run the application it simulataneously opens a Console as well.
Is it possible to have a button so that the Console would open only when I desire?
Also how I can use all the functionalities in my application from the console,right now only ctrlC works!
Thank you for any help and suggestions.
0
Comment
Question by:samroyc
  • 3
  • 2
6 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 13755826
Hi samroyc,
What is your motivation behind this?

David Maisonave :-)
Cheers!
0
 

Author Comment

by:samroyc
ID: 13755892
the application will be run by users remotely to control a device.I need to be able to get to the controls using console,
as a "superuser",just in case somethings go wrong or the prg crashes while communicating with the device etc...
So I need an option where in the console is also available.
Thanks
0
 
LVL 30

Expert Comment

by:Axter
ID: 13755914
>>So I need an option where in the console is also available.

Do you want this option when the program first starts up, or after there's a display?

IMHO, it would be better for a super user to have this feature via a special super user GUI window.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:samroyc
ID: 13755993
After a display is fine.
**IMHO, it would be better for a super user to have this feature via a special super user GUI window.**
I am not sure if I uderstand what this means,another application,or just another control button that opens
another window?
Thank you for your interest.
 
 
   
 
0
 
LVL 86

Accepted Solution

by:
jkr earned 1500 total points
ID: 13756053
>>Is it possible to have a button so that the Console would open only when I desire?

Sure, just make sure to 'manually' call 'AllocConsole()'. Then use

   int hCrt;
   FILE *hf;

   AllocConsole();
   hCrt = _open_osfhandle(
             (long) GetStdHandle(STD_OUTPUT_HANDLE),
             _O_TEXT
          );
   hf = _fdopen( hCrt, "w" );
   *stdout = *hf;
   i = setvbuf( stdout, NULL, _IONBF, 0 );
                        
to access the console window.

Check out http://support.microsoft.com/default.aspx?scid=kb;en-us;105305 ("INFO: Calling CRT Output Routines from a GUI Application")
0
 
LVL 30

Expert Comment

by:Axter
ID: 13767521
>>I am not sure if I uderstand what this means,another application,or just another control button that opens
>>another window?

Check out the following link:
http://www.codeguru.com/Cpp/controls/controls/coolcontrols/article.php/c8589/

The above project is an example of using a GUI window to enter command lines, like you would in console mode.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question