set smaller opengl window width like 64 - opengl

How to set the width of opengl window small under Windows 10, like 64.
It seems the window needs a certain width in order to contain 'maximum', 'colse' buttons.
Thanks a lot!

Related

What could be possible reasons that GetWindowRect() returns size which is smaller than actual visible window for a game?

I set game to a borderless window and it becomes full-screen with size 2560x1440.
Then I get window size:
GetWindowRect(hWnd, tSize);
And monitor size:
Width = GetSystemMetrics(SM_CXSCREEN);
Height = GetSystemMetrics(SM_CYSCREEN);
I receive values for a width being 2048 and 1152 for height . Same dimensions in tSize and in Width and Height. Basically system says that's yeah my window is equal to the size of my monitor, which is correct. But values are smaller, which is incorrect.
Same goes for windowed regime, values that I obtain are smaller(incorrect) than visible ones.
I tried other functions, and only time that I got correct dimensions for my monitor was with DirectX.
GetAdapterDisplayMode(adapter, &mode)
I know this is an old question but I would guess that your screen is scaled by 125% since the ratio of your actual height and real height is the same as your actual width verse width.

How to get invisible border size for window resize on windows 10

I have an application that aligns other apps windows into grid. The problem is invisible border size. I can get that border by using API calls GetWindowRect and DwmGetWindowAttribute with DWMWA_EXTENDED_FRAME_BOUNDS
But this doesn't work if the window is hidden. How can I get the size of that border for the hidden window or perhaps from the system?

SDL adjust window size

I want SDL window size to stay within working area (SPI_GETWORKAREA) of windows which excludes windows taskbar other panels.
The problem is that both SDL_CreateWindow and SDL_SetWindowSize set the client area of window, not the size including window borders. So when I set window size to fit on a small working area, the borders still go out of working area.
SDL_CreateWindow: Use this function to set the size of a window's client area.
Does SDL provide a way to set window size within working area? or how do I get border size of SDL window so that I can do that myself?
You don't even need WinAPI to do that.
The size of window borders can be determined by SDL_GetWindowBordersSize(), and the part of the display not occupied by taskbar should be returned by SDL_GetDisplayUsableBounds().
With these functions, maintaining a proper window position (and maybe size) should be easy.
The only way I know of (SDL 1.2) is to first create a small window (2x2 pixels) and then check the total window size using the Windows API (GetWindowPlacement). Based on this, you can calculate the parameters necessary to get the window size you are looking for, and finally resize the window (MoveWindow).
I hope someone has a better solution, because this is a very ugly workaround.

QGLWidget maximum size

I have a Qt application using OpenGL drawing with QGLWidget, on Mac OS.
On my MBP it works well, but when trying on a 30" screen, I noticed that there is a window size limit.
If I increase the window size beyond a certain limit, the QGLWidget's content disappears and only some greyish memory junk is visible.
I changed the code to only put a QGLWidget on the screen. The repaint event is setting the background black in each iteration.
The issue is still visible: when resizing the widget, the black surface disappears and gets replaced by the memory junk, when the size of the widget reaches a certain size.
Interesting facts:
When I decrease the window size, the GL surface comes back to live again
I have several other GL applications (not Qt) running in maximized window, so the issue is not with the OpenGL driver/video card
It seems that the area of the window (nr of pixels) matters, if I make the window very wide, it's height will be limited and vica versa, I if the windoe is maximized in height, the width must be small
I found that while instantiating the QGLWidget using QGLFormat(QGL::NoSampleBuffers) instead of QGLFormat(QGL::SampleBuffers) solves the issue.

MFC how to resize CStatic to a small size

I have the following issue with the CStatic control:
When I call function SetIcon:
m_CStatic.SetIcon(AfxGetApp()->LoadIcon(IDI_ICON1));
It loads an icon that have a size 14x14 pixels, but the actual size of the control becomes 21x20 and I can not to modify it.
I tried to call:
m_CStatic.SetWindowPos(NULL,0 , 0, 14, 14, SWP_NOMOVE);
But it only cuts a size without resizing of the icon. As result I have a part of zoomed image.
Is there any way to set a size of an icon to load?
EDIT
An actual size of the IDI_ICON1 is 14x14 pixels.
Also the size of the CStatic control is 21x20 and I can not change it with the designer.
When I load an icon it is stretched. I have no idea why.
An actual size of the IDI_ICON1 is 14x14 pixels.
Also the size of the CStatic control is 21x20 and I can not change it with the designer.
If you're looking at the size of the control in the designer, you're not comparing apples to apples here. The designer is reporting the size of controls in DLUs (dialog box units), not pixels.
There is not necessarily a 1-to-1 mapping between DLUs and pixels. In fact, the whole point of a DLU is that it is pixel-independent. The actual number of pixels represented by a single DLU will change depending on the fonts and DPI of the computer you're running the application on.
So the behavior you're seeing makes perfect sense to me.
If you don't believe this DLUs vs. pixels silliness, then try running the application under the debugger and using Spy++ to investigate the actual size (in pixels) of the static control. I'll bet it's 14x14.
And no, you cannot resize a static control in the designer if you have it set to display an icon. The control is automatically sized to accommodate the icon it is displaying. That's also by design. I can't imagine why you'd want to; your whole point seems to be that you don't want the icon to be clipped.
But like I said in a comment, static controls do not automatically scale their icons. You need to write code to do the icon scaling yourself (probably by calling the DrawIconEx function). Forcing the static control to resize itself will just crop the icon or add a border around it. Adding the SS_CENTERIMAGE style, as duDE suggested will alter this behavior so that the icon is aligned to the center of the static control, subtly changing how the cropping happens. But it will still get cropped to fit the static control's size.
Do be careful, though. The whole point of my line of questioning in the comments regarding the icon actually in IDI_ICON1 is that the LoadIcon function has some important limitations. Namely, it is only designed to load icons with the SM_CXICON and SM_CYICON sizes (on most systems, that will be 32x32). It does work as expected when you only have one icon defined in the icon resource, but it will fall apart otherwise. That could have been the explanation for the stretching. Instead, it's recommended that you use the LoadImage function. The code is rather more verbose, but it's a more powerful function:
HICON hIcon = static_cast<HICON>(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_ICON1),
IMAGE_ICON,
14, /* width (x dimension) */
14, /* height (y dimension) */
LR_DEFAULTCOLOR));
// (make sure to call DestroyIcon() on hIcon when you're done with it!)
Try this:
CStatic m_CStatic;
// Create a child icon static control
m_CStatic.Create(_T("my static"),
WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(0 , 0, 14, 14), pParentWnd);
// Set the icon
m_CStatic.SetIcon(::LoadIcon(IDI_ICON1));
The point is SS_CENTERIMAGE:
A bitmap is centered in the static control that contains it.
The control is not resized, so that a bitmap too large for the control will be clipped.