I have programmed a game running on console. The console host I chose to use is Window Console Host because I can easily and successfully setup and confiugre it with the API functions from <Windows.h>
. The game's window I expected was like below:
I had made the window of above console app not able to be resized by anyway. But when I released that app and sent to my friend to test, then it became like this because he was using Windows Terminal:
Is there any solution to make the released console app run with fixed console host on any computer to keep my setup?
Here is the code snippet I wanted to setup the console's window:
#include <Windows.h>
int main(void) {
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
HWND hWnd = GetConsoleWindow();
//set font size
CONSOLE_FONT_INFOEX cfi = { sizeof(cfi) };
// Populate cfi with the screen buffer's current font info
GetCurrentConsoleFontEx(hStdout, FALSE, &cfi);
// Modify the font size in cfi
//cfi.dwFontSize.X *= 2;
cfi.dwFontSize.Y = 36;
// Use cfi to set the screen buffer's new font
SetCurrentConsoleFontEx(hStdout, FALSE, &cfi);
//delete cursor
const CONSOLE_CURSOR_INFO CUR_INFO = { 10, 0 };
SetConsoleCursorInfo(hStdout, &CUR_INFO);
//set size of console
SMALL_RECT WindowSize = { 0, 0, CONSOLE_WIDTH, CONSOLE_HEIGHT};
SetConsoleWindowInfo(hStdout, 1, &WindowSize);
//remove console screen buffer. This command must be put after 'SetConsoleWindowInfo',...
//...and value of 'NewSize' must be greater than CONSOLE_WIDTH and CONSOLE_HEIGHT just 1
COORD NewSize = { CONSOLE_WIDTH + 1, CONSOLE_HEIGHT + 1 };
SetConsoleScreenBufferSize(hStdout, NewSize);
//disable resize console by mouse
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_SIZEBOX);
//disable maximizing
DeleteMenu(GetSystemMenu(hWnd, FALSE), SC_MAXIMIZE, MF_BYCOMMAND);
//Hide scroll bar
ShowScrollBar(hWnd, SB_BOTH, FALSE);
//disable select text by mouse
SetConsoleMode(hStdin, ~ENABLE_QUICK_EDIT_MODE);
//set title of console window
SetConsoleTitleW(TEXT("Console Run"));
}