Patrice

Category: PowerBASIC

Date: 02-16-2022

Return to Index


 
Sub DisplayThumbnail() {
    If (IsWindow(gP.hCapture)) {
        Long nItem = (Long) SendMessage(gP.hCapture, CB_GETCURSEL, 0, 0);
        If (nItem > -1) {
            HWND hWnd = (HWND) SendMessage(gP.hCapture, CB_GETITEMDATA, nItem, 0);
            gP.ComboItem = nItem;
            If (hWnd == gP.hList) {
                If (!gP.webcam) {
                    gP.webcam = TRUE;
                    SetHelpImage("WebCam.png", ID_HELP);
                    ZD_ShowObject(ID_HELP, TRUE);
                }
                If (gP.hThumbID) {
                    DwmUnregisterThumbnail(gP.hThumbID);
                    gP.hThumbID = 0;
                }
            } Else {
                gP.webcam = FALSE;
                If (IsWindow(hWnd)) {
                    gP.hWindow = hWnd;
 
                    If (gP.hThumbID) {
                        DwmUnregisterThumbnail(gP.hThumbID);
                        gP.hThumbID = 0;
                    }
 
                    HTHUMBNAIL hThumbID = 0;
                    If (DwmRegisterThumbnail(gP.hMain, gP.hWindow, &hThumbID) == S_OK) {
                        gP.hThumbID = hThumbID;
 
                        //UpdateThumbnail();
                        DWM_THUMBNAIL_PROPERTIES p = { 0 };
                        p.dwFlags = DWM_TNP_RECTDESTINATION | DWM_TNP_OPACITY | DWM_TNP_VISIBLE;// | DWM_TNP_SOURCECLIENTAREAONLY;
                        p.fSourceClientAreaOnly = FALSE;
                        p.fVisible = TRUE;
                        p.opacity = 255;
 
                        Long x = 0, y = 0, w = 0, h = 0;
                        RECT r = { 0 }; GetWindowRect(gP.hGDImage, &r);
                        Point pt = { r.left, r.top };
                        ScreenToClient(gP.hMain, &pt);
                        ZI_Iconise(Width(gP.rID), Height(gP.rID), Width(r), Height(r), x, y, w, h);
                        x += pt.x; y += pt.y;
                        If (gP.bSkin) {
                            x += skGetSystemMetrics(SK_CXFRAMELEFT);
                            y += skGetSystemMetrics(SK_CYCAPTION);
                        }
 
                        SetRect(&p.rcDestination, x, y, x + w, y + h);
 
                        If (DwmUpdateThumbnailProperties(gP.hThumbID, &p) == S_OK) {
 
                        }
 
                    }
                }
            }
        }
    }
}
 


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