CDialogEx:: OnNCPaint() increases the size of dialog window - mfc

I need to draw custom title bar, using Win10, VS2017, MFC, SDK10.0.16299.0.
When MyDialog::OnNcPaint() does not call CDialogEx::OnNcPaint(), the dialog frame is drawn incorrectly - the top corners are rounded while bottom corners are sharp, and dialog size increases in couple of pixels.
I need to keep the dialog in original size and shape. Any suggestions please ?

Related

QT Resize border thickness for QDockWidget

I'm working on a dockable widget using QDockWidget.
It all works so far but the problem is that when I undock it and want to resize it by grabbing the window edge with the mouse, the border where I can resize it seems to be about 1pixel thick, making it very fiddly to try to grab.
Is there any way of specifying a thicker resize border so that the users don't have to re-try 7 times to try to grab it?

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.

When should I resize a Direct3D 11 backbuffer to prevent it being drawn stretched during resize?

I've created a Direct3D 11 application that allows the window to be resized. I am drawing 2D content, and I want it to stay the same size regardless of what I do to the window, so e.g. shrinking the window from the lower-right corner should hide anything on the right or bottom, but leave anything in the upper-left stationary.
However, although I am resizing the back buffer in response to WM_SIZE as described in the documentation for IDXGISwapChain::ResizeBuffers, I still see the window contents stretch or squish for a few moments while resizing before it corrects itself. This makes the window contents appear to fluctuate up and down in size while I drag the window to its new size.
It turns out that when creating the swap chain, I left my DXGI_SWAP_CHAIN_DESC1's Scaling field zero-initialized, which turns out to be DXGI_SCALING_STRETCH. Switching to DXGI_SCALING_NONE fixed the problem (and reduced how often I needed to resize the back buffer).

Cut a window with a triangle shape from top most right corner

We have two windows out of which one window is a small triangular shaped window used to display with a certain size in triangular format on top most right corner of desktop.
The 2nd window is a full screen mode window (Maximized window).
So, my requirement says that the 2nd window should be displayed in full screen mode such that it does not hide the 1st triangular window. I have the liberty to cut the full screen window size up to the size of triangular window.
PS: I can not use the TOP_MOST window property to always display triangular window on top of screen.
Attached: An expected window layout:

Reposition dialog controls when resizing a dialog so that they are consistent between operating systems using mfc C++

Currently I'm repositioning dialog controls when the dialog is resized like this:
// Get the list control rect.
CRect listRect;
list->GetWindowRect(&listRect);
ScreenToClient(listRect);
// Get the dialog Rect.
CRect dialogRect;
GetWindowRect(&dialogRect);
ScreenToClient(dialogRect);
list->MoveWindow(listRect.left, listRect.top,
dialogRect.right - (2 * listRect.left), dialogRect.bottom - 100);
This works great in Windows XP, but when I tried in Windows Vista the positioning was off. I think this must be down to larger dialog borders and captions in Windows Vista dialogs, and the fact that GetWindowRect has the following entry in the documentation:
The dimensions are given in screen coordinates relative to the upper-left corner of the display screen. The dimensions of the caption, border, and scroll bars, if present, are included.
So my question is, how do I reposition dialog controls when resizing a dialog so that they are consistent between operating systems? Thanks
You should use GetClientRect instead of GetWindowRect followed by ScreenToClient -- the former returns the extents of the client part of the window (i.e. without borders), whereas the latter retrieves the extents of the whole window including non-client parts (albeit in client coordinates).
// Get the list control rect.
CRect listRect;
list->GetWindowRect(&listRect);
dlg->ScreenToClient(&listRect);
// Get the dialog Rect.
CRect dialogRect;
dlg->GetClientRect(&dialogRect);
list->MoveWindow(listRect.left, listRect.top, dialogRect.right - (2 * listRect.left), dialogRect.bottom - 100);