close the console once GUI is loaded?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: close the console once GUI is loaded?

  1. #1
    Join Date
    Jul 2009
    Location
    Bangalore, INDIA
    Posts
    45

    Question close the console once GUI is loaded?

    Hello,

    My application needs to be started through console.. Or in other words, on double clicking, myprog.exe, a small terminal opens, which leads a GUI window to be displayed.. What i want is to close the console once my GUI is loaded. How can i do this.??

    Thanks

  2. #2
    Arjay's Avatar
    Arjay is online now Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,217

    Re: close the console once GUI is loaded?

    Create a console with:

    Code:
    // Allocate a new console.
    AllocConsole();
    	
    // Redirect stdout to the console.
    _tfreopen( _T("CONOUT$"), ("a+t"), stdout);
    When you're done with it...

    Code:
    FreeConsole( );
    Consult msdn for options with regard to _tfreopen params.


    __________________________________________________________
    Arjay

    See my latest series on using WCF to communicate between a Windows Service and WPF task bar application.
    Tray Notify - Part I Tray Notify - Part II

    Need a little help with Win32 thread synchronization? Check out the following CG articles and posts:
    Sharing a thread safe std::queue between threads w/progress bar updating
    Simple Thread: Part I Simple Thread: Part II
    Win32 Thread Synchronization, Part I: Overview Win32 Thread Synchronization, Part 2: Helper Classes

    www.iridyn.com


  3. #3
    Join Date
    Jul 2009
    Location
    Bangalore, INDIA
    Posts
    45

    Re: close the console once GUI is loaded?

    Hi..

    By doing this, will i be able to view only GUI app..? or along with that separate console will be coming..??

    I dont want console at all to be displayed.. its ok if it is running in background or invisible..

    Thanks

  4. #4
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: close the console once GUI is loaded?

    Code:
    int main()
    {
    	::ShowWindow(::GetConsoleWindow(), SW_HIDE);
    	// ...
    }
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  5. #5
    Arjay's Avatar
    Arjay is online now Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,217

    Re: close the console once GUI is loaded?

    Quote Originally Posted by rakeshthp View Post
    Hi..

    By doing this, will i be able to view only GUI app..? or along with that separate console will be coming..??

    I dont want console at all to be displayed.. its ok if it is running in background or invisible..

    Thanks
    Why not try the code I posted and find out? Then try Ovidio's code.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center