Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: That annoying little window  (Read 8355 times)

0 Members and 1 Guest are viewing this topic.

David

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
That annoying little window
« on: April 27, 2011, 11:55:37 pm »
I just started using SFML a few days ago :shock:

Whenever I run the code in Code::Blocks, the little CP-like window (I forgot what it's called) pops up along with the window that displays the images :evil:

How do you get rid of this window by code :?:

cooldog99

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
    • Perilous Game Studios
That annoying little window
« Reply #1 on: April 28, 2011, 01:03:19 am »
You don't need code to remove the console window :)

Project -> Properties -> Build Type -> it SHOULD say Console application, change it to Gui Application.
Make sure to set it to same on Debug AND release (on left) or whichever you prefer :D

Note: May require you to restart codeblocks, sometimes it does for me.

Hope this helps.

Mjonir

  • Full Member
  • ***
  • Posts: 142
    • View Profile
That annoying little window
« Reply #2 on: April 28, 2011, 01:10:10 am »
On that subject, does anyone know if it's possible to do the opposite, i.e. forcing the console to appear in GUI Application (through code)?

It would be really nice for me if it was possible to control that through code (even an ugly piece) so that I could avoid making 2 different versions of my program and control that with a bool :P

cooldog99

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
    • Perilous Game Studios
That annoying little window
« Reply #3 on: April 28, 2011, 01:25:10 am »
Quote from: "Mjonir"
On that subject, does anyone know if it's possible to do the opposite, i.e. forcing the console to appear in GUI Application (through code)?

It would be really nice for me if it was possible to control that through code (even an ugly piece) so that I could avoid making 2 different versions of my program and control that with a bool :P


Why not just have a Console application? ;)

Otherwise you'll have to use some winAPI functions to call the console window, I forget exactly how as I hate using Windows.h heh.

Don't forget you can have multiple build targets in codeblocks (or other IDE's)

Mjonir

  • Full Member
  • ***
  • Posts: 142
    • View Profile
That annoying little window
« Reply #4 on: April 28, 2011, 01:31:39 am »
My project is aimed at both scripters (who really need the console) and their end-users (who don't need/want to see the console). So at the moment I do have multiple build targets, but I'd be force to release two different versions of my program, one with the console and one without. If I could control that in the application itself, I could only give only one build and control that in the configuration file. It's not an absolute need, but it'd be neater if it's easy enough to control.

I'll have a look at Windows.h then. I hope it wouldn't break portability too much to do it this way though :?

David

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
That annoying little window
« Reply #5 on: April 28, 2011, 01:55:46 am »
Quote from: "cooldog99"
You don't need code to remove the console window :)

Project -> Properties -> Build Type -> it SHOULD say Console application, change it to Gui Application.
Make sure to set it to same on Debug AND release (on left) or whichever you prefer :D

Note: May require you to restart codeblocks, sometimes it does for me.

Hope this helps.


Wow, jeez, I comPLETELY forgot about the GUI application option :shock:

Thanks a bunch  :D

Fred_FS

  • Newbie
  • *
  • Posts: 48
    • View Profile
That annoying little window
« Reply #6 on: April 28, 2011, 02:21:03 am »
Quote from: "Mjonir"
My project is aimed at both scripters (who really need the console) and their end-users (who don't need/want to see the console). So at the moment I do have multiple build targets, but I'd be force to release two different versions of my program, one with the console and one without. If I could control that in the application itself, I could only give only one build and control that in the configuration file. It's not an absolute need, but it'd be neater if it's easy enough to control.

I'll have a look at Windows.h then. I hope it wouldn't break portability too much to do it this way though :?

It is probably not as easy as you wish. Once you have created a new console-window you  have for example to redirect the standard input and output streams to this window.
It is possible and described here, but it is rather complicated.

But I have an easy suggestion for you. Just create a console-application and if you don't want to show the console window, use
Code: [Select]

ShowWindow(GetConsoleWindow(), SW_HIDE);

to hide it(Further information).

I think hiding an existing console is easier than creating a new one ;).

David

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
That annoying little window
« Reply #7 on: April 28, 2011, 02:45:30 am »
Quote from: "Fred_FS"
Quote from: "Mjonir"
My project is aimed at both scripters (who really need the console) and their end-users (who don't need/want to see the console). So at the moment I do have multiple build targets, but I'd be force to release two different versions of my program, one with the console and one without. If I could control that in the application itself, I could only give only one build and control that in the configuration file. It's not an absolute need, but it'd be neater if it's easy enough to control.

I'll have a look at Windows.h then. I hope it wouldn't break portability too much to do it this way though :?

It is probably not as easy as you wish. Once you have created a new console-window you  have for example to redirect the standard input and output streams to this window.
It is possible and described here, but it is rather complicated.

But I have an easy suggestion for you. Just create a console-application and if you don't want to show the console window, use
Code: [Select]

ShowWindow(GetConsoleWindow(), SW_HIDE);

to hide it(Further information).

I think hiding an existing console is easier than creating a new one ;).


So would
Code: [Select]
ShowWindow(GetConsoleWindow(), SW_SHOW); also work?

Fred_FS

  • Newbie
  • *
  • Posts: 48
    • View Profile
That annoying little window
« Reply #8 on: April 28, 2011, 11:24:19 am »
As I mentioned in my last post, this would not work. At least not, if you're running a "Gui Application".
A window that does not exist will not be shown ;).

If you're using a console application, you can make your console visible again by using your code.

eglomer

  • Newbie
  • *
  • Posts: 13
    • View Profile
That annoying little window
« Reply #9 on: August 09, 2011, 12:37:09 pm »
If you need the console window but you don't want to show it always, you can use this code to show/hide it:

Code: [Select]
#include <windows.h>

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
class ConsoleWindow{
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
private:
HWND CONSOLE;

public:
ConsoleWindow(void);
void HideConsoleWindow (void);
void ShowConsoleWindow (void);
};


//----------------------------------------------------------------------------------------------------
ConsoleWindow::ConsoleWindow (void){
//----------------------------------------------------------------------------------------------------
SetConsoleTitle("- Console Window -");
sf::Sleep(1);
this->CONSOLE = FindWindow(NULL, "- Console Window -");
}

//----------------------------------------------------------------------------------------------------
void ConsoleWindow::HideConsoleWindow (void){
//----------------------------------------------------------------------------------------------------
ShowWindow(this->CONSOLE, SW_HIDE);
}

//----------------------------------------------------------------------------------------------------
void ConsoleWindow::ShowConsoleWindow (void){
//----------------------------------------------------------------------------------------------------
ShowWindow(this->CONSOLE, SW_SHOW);
}