Qt, Ruby, Windows API, Dwmapi : Display windows thumbnails

If like me you are crazy enough to try to make Qt apps using Ruby, and want to use Windows API to display thumbnails of windows, here is how. The hard part is that you have to pack the dskThumbProps struct before calling DwmUpdateThumbnailProperties from Dwmapi. It's a dumb API: You call it and place it at arbitrary coordinates on the window.

$DwmUpdateThumbnailProperties = Win32API.new "Dwmapi.dll","DwmUpdateThumbnailProperties", 'LP'
DWM_TNP_VISIBLE = 0x00000008
DWM_TNP_RECTDESTINATION = 0x00000001
DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010
# Here you should call DwmRegisterThumbnail and set x, y, width and height.
dskThumbProps = [
DWM_TNP_VISIBLE | DWM_TNP_RECTDESTINATION | DWM_TNP_SOURCECLIENTAREAONLY,
[x, y, x + width, y + height].pack('l4'),
'',
255,
1,
1
].pack("La16a16III")
$DwmUpdateThumbnailProperties.call(thumbId, dskThumbProps)