I have an application that has a subclass of WPF HwndHost. This sub-class overrides the HwndHost::BuildWindowCore method and creates a native HWND. I then create a D3D 11 swap chain using that native widow, draw some stuff into it and present it. As
there is no animation in the DX image I am displaying I only re-render based on WM_PAINT messages I get by overriding the HwndHost::WndProc in my sub class
This all works as expected on Windows 8, I don't get many WM_PAINT message as I assume the DWM is using my back buffer to re-compose the screen as windows move around, get iconized etc...
However I then ported the program to Window 7 and the exact same code has different behavior. I get WM_PAINT message whenever any of my HWND gets exposed, say by dragging another window over it. I was assuming that the DWM, or whatever handles this for my on Windows 8 would do the same on Windos 7. So does anyone know if there is some magic I must perform to not get spammed with WM_PAINT on Windows 7?
The following shows some of the relevant code, BTW this is all in C++/CLI
// Window creation in BuildWindowCore
hWnd = CreateWindowEx(
0,
L"static",
L"HWndHostEx",
WS_CHILD | WS_VISIBLE,
0, 0, // x, y
300, 300, // height, width
parentHWnd, // parent hwnd
0, // hmenu
0, // hinstance
0 ); // lparam
// Swap chain creation
DXGI_SWAP_CHAIN_DESC dxgiSwapChainDesc;
dxgiSwapChainDesc.BufferCount = 2;
dxgiSwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
dxgiSwapChainDesc.BufferDesc.Width = static_cast<UINT>( d3dViewPort.Width );
dxgiSwapChainDesc.BufferDesc.Height = static_cast<UINT>( d3dViewPort.Height );
dxgiSwapChainDesc.BufferDesc.Format = Color::getDXGIFormat( );
dxgiSwapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
dxgiSwapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
dxgiSwapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
dxgiSwapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
dxgiSwapChainDesc.SampleDesc.Quality = 0;
dxgiSwapChainDesc.SampleDesc.Count = 1;
dxgiSwapChainDesc.OutputWindow = hWnd;
dxgiSwapChainDesc.Windowed = true;
dxgiSwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
dxgiSwapChainDesc.Flags = 0;
dxgiSwapChain1 = dxDevice->CreateSwapChain1( dxgiSwapChainDesc );
Present Call
dxgiSwapChain1->Present( 1, 0 );
So basically 2 buffers in the swap chain and a synced Present call. The graphics cards are pretty similar, a Radeon HD 8700 on the Windows 7 box and an Radeon 8600 on the Windows 8.
Any suggestions gratefully received.