How Can I Disable Maximize Button for Console Window?
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...
Code:
#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
Re: How Can I Disable Maximize Button for Console Window?
try this
Code:
DWORD newStyle = WS_CAPTION | DS_MODALFRAME | WS_MINIMIZEBOX | WS_SYSMENU;
SetWindowLong(hConsole , GWL_STYLE, newStyle);
SetWindowPos(hConsole , NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
I hepe it works.
regards
Re: How Can I Disable Maximize Button for Console Window?
Quote:
Originally Posted by
Ali Imran
try this
Code:
DWORD newStyle = WS_CAPTION | DS_MODALFRAME | WS_MINIMIZEBOX | WS_SYSMENU;
SetWindowLong(hConsole , GWL_STYLE, newStyle);
SetWindowPos(hConsole , NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
I hepe it works.
regards
Thanks for your support. I already solved it several weeks ago...I appreciate your help
Re: How Can I Disable Maximize Button for Console Window?
Quote:
Originally Posted by
Ali Imran
try this
Code:
DWORD newStyle = WS_CAPTION | DS_MODALFRAME | WS_MINIMIZEBOX | WS_SYSMENU;
SetWindowLong(hConsole , GWL_STYLE, newStyle);
SetWindowPos(hConsole , NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
I hepe it works.
regards
Your code functions almost perfectly, the only thing I found was you need to add SWP_SHOWWINDOW as paramenter.
Code:
SetWindowPos(hConsole , NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
Otherwise the console is hidden.