DWM Chen

Category: PowerBASIC

Date: 02-16-2022

Return to Index


 
#define STRICT
#include <windows.h>
#include <windowsx.h>
#include <ole2.h>
#include <commctrl.h>
#include <shlwapi.h>
#include <stdio.h>
#include <dwmapi.h>
 
HINSTANCE g_hinst;                          /* This application’s HINSTANCE */
HWND g_hwndChild;                           /* Optional child window */
HTHUMBNAIL g_hthumb;
 
 
BOOL
OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
  DWM_THUMBNAIL_PROPERTIES props = {};
  HWND hwndTarget;
  if (sscanf(reinterpret_cast<PCSTR>(lpcs->lpCreateParams),
               “%p %ld %ld %ld %ld”, &hwndTarget,
               &props.rcSource.left, &props.rcSource.top,
               &props.rcSource.right, &props.rcSource.bottom) == 5) {
    DwmRegisterThumbnail(hwnd, hwndTarget, &g_hthumb);
    props.dwFlags = DWM_TNP_VISIBLE | DWM_TNP_RECTSOURCE |
                    DWM_TNP_RECTDESTINATION;
    props.rcDestination = props.rcSource;
    OffsetRect(&props.rcSource,
               -props.rcSource.left, -props.rcSource.top);
    props.fVisible = TRUE;
    DwmUpdateThumbnailProperties(g_hthumb, &props);
  }
  return TRUE;
}  
 
 
void
OnDestroy(HWND hwnd)
{
  if (g_hthumb) DwmUnregisterThumbnail(g_hthumb);
  PostQuitMessage(0);
}
 
 
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,
                   LPSTR lpCmdLine, int nShowCmd)
{
   …
 
 
        hwnd = CreateWindow(
            “Scratch”,                      /* Class Name */
            “Scratch”,                      /* Title */
            WS_OVERLAPPEDWINDOW,            /* Style */
            CW_USEDEFAULT, CW_USEDEFAULT,   /* Position */
            CW_USEDEFAULT, CW_USEDEFAULT,   /* Size */
            NULL,                           /* Parent */
            NULL,                           /* No menu */
            hinst,                          /* Instance */
            lpCmdLine);
    …
}


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm