title: DwmRegisterThumbnail for UWP app
body: <p>I'm working on a UWP app that provides task-switching capabilities for users with complex physical limitations. This question is related to trying to provide the live thumbnails like alt-tab and the taskbar do. So far, much of the functionality has been made possible through an in-process full-trust component making the necessary (winapi) calls and passing information back to the UWP app.</p>
  
  <p>I made a test WPF app utilizing <code>DwmRegisterThumbnail</code> and <code>DwmUpdateThumbnailProperties</code> and it works fine.</p>
  
  <p>However, when I attempt to implement this in the UWP/full-trust app, registration fails with <code>E_INVALIDARG</code>. According to <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa969521%28v=vs.85%29.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">MSDN</a>, this can be because the source or destination windows are not top-level windows. In this case, the destination window is the window handle for the UWP app, and the source window is explorer.exe (file explorer, in this case). Both are enumerated by <code>EnumWindows</code> and aren't children of other windows.</p>
  
  <p>Is the problem that the full-trust side is calling <code>DwmRegisterThumbnail</code>? I tried making the calls from the UWP side as well, but got the same result. I wouldn't really expect to be able to make those calls from the UWP side anyway, since it would seem to violate the sandboxed nature of it. Is there any way to do this?</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>I tried doing a C++ UWP proof-of-concept, but couldn't reference anything DWM-related. Then I found <a href="https://docs.microsoft.com/en-us/uwp/win32-and-com/alternatives-to-windows-apis-uwp" rel="nofollow noreferrer">this</a>. Looks like DWM isn't available at all to UWP.</p>
  
  <p>I'm guessing the full-trust component can't register the UWP app to be drawn to because, according to <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa969521%28v=vs.85%29.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">this</a>:</p>
  
  <blockquote>
    <p>The window designated by hwndDestination must either be the desktop
    window itself or be owned by the process that is calling
    DwmRegisterThumbnail. This is required to prevent applications from
    affecting the content of other applications.</p>
  </blockquote>
  
  <p>As stated above, I tried having the full-trust component call <code>DwmRegisterThumbnail</code>, using the handle of the host UWP app, but it doesn't appear to work, presumably because it isn't owned by the UWP process?</p>
  
  <p>Does anyone know of alternative methods that could be used to accomplish a thumbnail/window preview?</p>