PDA

View Full Version : Window offset



ToolTech
11-13-2017, 11:49 PM
When creating a top application window on windows 10 i now get a opengl rendering Surface that is extended 8 pixel to the left under the window decorations and 31 pixel under the titlebar. Is there any flag to disable this behaviour at window Creation time as it breaks window compatibility ?

I can see that it is realted to the WM_NCCALCSIZE (https://msdn.microsoft.com/en-us/library/windows/desktop/ms632634(v=vs.85).aspx) event that somehow Changes the client area within the window. I would like to disable this behaviour of my application window.

I guess that windows with Aero enabled in windows 10 adds a transparent border of 8x31 pixels. Only happends for the topmost window. Does not happend for popup or fullscreen windows

Dark Photon
11-14-2017, 07:16 AM
Are you calling AdjustWindowRect() before CreateWindow() (or SetWindowPos()) to let the OS bloat the window bounds to account for the frame, border, and caption pixels?:


RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = width;
rect.bottom = height;
AdjustWindowRect( &rect, winStyle, FALSE );

HWND win = CreateWindow( "className", "My Window", winStyle,
winOriginX, winOriginY,
( rect.right - rect.left ), // Adjusted width
( rect.bottom - rect.top ), // Adjusted height
NULL, NULL, instance, NULL);

Related reading:



MFC dialog Border padding changed after switching from VS2010 to 2012 or later (https://stackoverflow.com/questions/33880221/mfc-dialog-border-padding-changed-after-switching-from-vs2010-to-2012-or-later)
GetWindowRect on non-resizable windows under Aero Glass (https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/6c1c67a9-5548-4e9b-989f-c7dbac0b1375/getwindowrect-on-nonresizable-windows-under-aero-glass?forum=windowsuidevelopment)
GetWindowRect returns a size including “invisible” borders (https://stackoverflow.com/questions/34139450/getwindowrect-returns-a-size-including-invisible-borders)

ToolTech
11-14-2017, 07:48 AM
Yes you are right but.... That can be done and that will extend the size of the window at creation time and then updated by the NCCALCSIZE.It will then receive the expected size on WM_SIZE then but if i create a viewport using this size with glViewport i wont get the modelview transform right.

E.g. i have an app that in a traditional non aero environment creates a perfect quad in an perspective view. A unit modelview and an outline from -1 to 1 in x and y will create a perfect outline of the window extent. The same works in a window mode where i use full screen or a Child window in windows 10.

BUT in a top application that is adjusted with AdjustWindowRect i get exactly the same size of WM_SIZE but now the quad i located outside the visible window. That means that the mapping made by gzViewport dosnt map to the WM_SIZE window so the presentation is wrong. All values in the application regarding size and vieweport are the same

Perhaps this is a NVidia driver bug...

mhagain
11-14-2017, 08:01 AM
GetClientRect (https://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx) is your friend.

Only resetting your viewport on a resize event is actually a total micro-optimization; all that the viewport does is set a few state bits and transforms; you can safely make a GetClientRect call at the start of each frame, calculate new viewport bounds from that, and make a glViewport call each frame, and trust me - you will not notice one microsecond of measurable performance difference.

ToolTech
11-14-2017, 08:15 AM
What i am trying to explain is that is exactly what i do and I get the same values from VM_SIZE. However in the top view window application the scaling is wrong. In the fullscreen ist correct and in a non aero window its correct. Exactly the same values are received in the VM_SIZE event

ToolTech
11-14-2017, 02:29 PM
Its a driver issue. It happends on Intel 4.4.0 opengl drivers. Works ok on Intel 4.3.0 and on NVidia 385->

Solved...