Prevent automatic window size downscaling with small screen resolution?

I made a program that runs a Windows window with a width of 1350 and height of 626. It runs fine in a 1366x768 screen resolution, but when I reduce the width of the screen resolution, the window's width automatically gets scaled down with it and it messes up stuff. For example, a certain button is drawn on 100,500 at the 1366x768 screen resolution and at 100,400 at a smaller resolution, but it responds to a mouse click at 100,500 on both resolutions.

How do I prevent this automatic downscaling? I don't mind that part of the window is not visible on the screen; I can drag it sidewards via the top bar.
See code below...

Thanks in advance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
int width = 1350, height = 626;

....

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
	MSG msg;
	WNDCLASS wc;
	RECT WindowRect = {0, 0, width, height};
	hInstance = GetModuleHandle(NULL);
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc = (WNDPROC) WndProc;
	wc.cbClsExtra = wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "OpenGL";
	RegisterClass(&wc);
	AdjustWindowRectEx(&WindowRect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
	hWnd = CreateWindowEx(0, "OpenGL", "Leksikon", WS_OVERLAPPEDWINDOW, 0, 0, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, hInstance, NULL);
	static PIXELFORMATDESCRIPTOR pfd = {sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0};
	hDC = GetDC(hWnd);
	SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
	hRC = wglCreateContext(hDC);
	wglMakeCurrent(hDC, hRC);
	ShowWindow(hWnd, SW_SHOW);
	SetForegroundWindow(hWnd);
	SetFocus(hWnd);
	wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
	wglSwapIntervalEXT(0);
	SDL_Init(SDL_INIT_EVERYTHING);
	base = glGenLists(224);
	HFONT font = CreateFont(-16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE|DEFAULT_PITCH, "Courier New");
	HFONT oldfont = (HFONT)SelectObject(hDC, font);
	wglUseFontBitmaps(hDC, 32, 224, base);
	SelectObject(hDC, oldfont);
	DeleteObject(font);
	time_t seconds;
	time(&seconds);

....
Last edited on
I'm not sure why the OS would not respect the values in CreateWindowEx(), but I guess it will be forced to respect them if you disallow window sizing. To do this, create a window that doesn't have the WS_THICKFRAME window style (included in WS_OVERLAPPEDWINDOW).
That method prevents manual window sizing (by dragging the borders), but not automatic window sizing.
Topic archived. No new replies allowed.