2

I have a program that renders to a D3D11 swapchain created with IDXGIFactory2::CreateSwapChainForHwnd. It clears the swap chain to a particular color, specifically green, and draws a textured rectangle. Following the guide at https://learn.microsoft.com/en-us/windows/desktop/dwm/customframe, I extended the window caption downward using DwmExtendFrameIntoClientArea and I extended the client area to the entire window by handling the WM_NCCALCSIZE message. When the swap chain is presented, the contents of the swap chain buffer is drawn on top of the window, completely covering the DWM-drawn glass frame and caption buttons. How can I leave regions of the glass frame and caption buttons to be drawn by DWM while still drawing in the window frame using D3D11?

I have already tried to clear the RenderTargetView to a color of {0.0f, 0.0f, 0.0f, 0.0f} with ID3D11DeviceContext::ClearRenderTargetView but the alpha component appears to be ignored. I've tried to specify DXGI_ALPHA_MODE_STRAIGHT and DXGI_ALPHA_MODE_PREMULTIPLIED in the AlphaMode member of the DXGI_SWAP_CHAIN_DESC1 used to create the swap chain, but it crashes because alpha-blended swapchains must be created by CreateSwapChainForComposition or CreateSwapChainForCoreWindow. Those functions are not viable since I would like to support Windows 7.

Another thing I've tried is creating a blend state and making parts of the texture transparent. All this does is blend the transparent parts of texture with the clear color. Nothing is getting rendered by DWM though.

Akela
  • 21
  • 3
  • updated your title to more clearly reflect your question – xaxxon May 09 '19 at 00:58
  • 1
    You may need to set the viewport to a smaller (inner) rectangle in order to exclude the glass portion of the window: https://learn.microsoft.com/en-us/windows/desktop/api/d3d11/nf-d3d11-id3d11devicecontext-rssetviewports – VuVirt May 09 '19 at 13:03
  • I don't think I can set the viewport to exclude the glass portion of the window because I want to draw things in the title bar while leaving the desktop compositor to fill in some parts too, like the way Google Chrome draws the tab strip in Windows 7. – Akela May 12 '19 at 00:48
  • `CreateSwapChainForComposition` and `CreateSwapChainForCoreWindow` seem to be supported in Windows 7 with this [platform](https://learn.microsoft.com/en-us/windows/desktop/direct3darticles/platform-update-for-windows-7) update installed. – Drake Wu May 28 '19 at 02:23
  • On the website you linked, it says that DirectComposition is not available with that platform update. Further, I downloaded a [sample](https://github.com/oberth/custom-chrome) that uses DirectComposition to render in the window frame and it crashes on my Windows 7 computer because dcomp.dll is missing. – Akela Jun 02 '19 at 02:24

0 Answers0