How Can I Disable Maximize Button for Console Window? C++

I need to make my console application in a fixed size window & disable the maximize button. Can you give me any suggestions please?

I tried to do the following for setting the size, but its does not have any effect to the console window size, it does not work even though the code compiles...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <windows.h> 
using namespace std;

HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

int main() {
    SMALL_RECT windowSize = {0, 0, 100, 100};
    SetConsoleWindowInfo(hConsole, TRUE, &windowSize);
    SetConsoleTitle(L"TEST");
    cout<<"\nPlease press enter to exit"<<endl;
    cin.get();
    return 0;
}


My requirements in short are:

1. Disable maximize button
2. Set fixed size for console window
3. Add an icon beside the title name
4. Change the font of the text in the screen

I program in C++ under windows Vista, if you can tell me the proper functions, this can help!

Thanks
I don't think your able to do this. Your application doesn't own or control the Console window. It's merely run within this window/application (kinda like a VM).

>I don't think your able to do this. Your application doesn't own or control the Console window

?????
Of course you can do it. It's even a win32 FAQ !!!
Hm i agree with george, thats what i knew....
Yes, a console window handle is like any other window handle.
Only the wndproc is managed by csrss.exe...
Last edited on
I'd love a link to this entry in the Win32 FAQ.

I don't know too much about this, but if your program is a console program you can't modify the console window since the OS calls it for your program; however if you program creates a console window (AllocConsole() or some equivalent), perhaps then you can edit it properly?
Here's the article:
http://support.microsoft.com/kb/818361

However, it should be noted that it works by using a crufty hack on the crss.exe process (console applications don't have minimize,etc buttons and the like) and it affects all applications running under that window. (So, for example, if you run your application from the command-line, the console window gets modified, and remains modified after your application terminated.)

If you really want to do this, I suggest you first make sure you are using your own console window (close any existing then allocate a new one) when your program starts.


Frankly, though, I'll say again that you are doing something that console applications aren't supposed to do. Font, buttons, etc are all the user's perview --not your applications. Vista has made it even harder to do weird stuff with the console window than previously possible, all because of this very fact.

I recommend that you reconsider why you want to do this stuff. If you discover that it is essential to your application --then write yourself a GUI application and forget the console stuff. Otherwise, don't mess with the GUI and leave it to the user's preferences like you are supposed to.

Hope this helps.
Last edited on
@Duoas: I was trying to point out another blatantly BS post by George. Who simply just posts something stating that the information is available elsewhere without ever providing code or a link.

I had found that link and I fired up that code provided and tested it on WindowsXP. It doesn't remove the button, but it greys it out and disabled it. Unfortunately, this only works for the close button. It will disable the functionality of the Min/Max buttons, but doesn't remove or grey them out. A crude hack at best imo.
Kid Zaita, If you are not even able to click on Search on Google or Google Groups or BBS or MSDN for a question answered dozens of times for 16 years, it's really a big problem...
And apparently, you even don't understand what is a win32 style (!) or what is csrss...
...and I won't talk about SetConsoleFont() and others Native or Kernel win32 apis...
Last edited on
George, you better shut your yap while you are ahead. Zaita is light-years ahead of you in understanding all things binary.

If you continue to post agressive, depreciative stuff about others I will report you to the forum administrators. They don't take too kindly to your kind of personal assaults. So just stop.

For future reference, please post links to MS articles for people. MSDN is notorious for moving pages around.

Later
--Michael
Actually, I did search for it in google. And the best article you can find is the one posted by Duoas. So clearly he is unable to use google either =\

Your failure again to provide a concrete link to an article or FaQ in question merely enforces my comments. I actually did a search, downloaded and tested the code only to find significant problems with it's execution. What have you done?

Edit: Yea, I see no reason for you to get immediately personaly. I am merely pointing out a flaw in your posting technique. I have yet to see a post from you that contained a link or anything more substantial than "its on MSDN" or "the win32 faq" or "the win32 api".

This forum is about helping people, not providing empty unhelpful replies to their questions.
Last edited on
Topic archived. No new replies allowed.