|
-
January 4th, 2009, 04:52 PM
#1
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
-
January 25th, 2009, 11:33 PM
#2
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
-
January 25th, 2009, 11:53 PM
#3
Re: How Can I Disable Maximize Button for Console Window?
 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
-
August 25th, 2019, 10:34 AM
#4
Re: How Can I Disable Maximize Button for Console Window?
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|