Quantcast
Channel: SCN : All Content - PowerBuilder Developer Center
Viewing all articles
Browse latest Browse all 2935

Capturing a screenshot does not work in PB 12.6 anymore

$
0
0

Hi,

 

I use the code of TopWiz to capure screenshots of a window. It seems that the sample doesn not work with PB 12.6 anymore (works fine for PB 11.5). The strange is: Copying to clipboard is good, but saving will end up in corrupted file. Maybe there is another behaviour handling blobs in PB.

 

Any ideas?

 

 

// capture bitmap and return as blob
ULong lul_hdc, lul_hdcMem, lul_hBitmap, lul_pixels
Blob lblb_header, lblb_info, lblb_bitmap
BitmapInfo lstr_Info
BitmapFileHeader lstr_Header
// Get the device context of window and allocate memory
lul_hdc = GetDC(aul_hWnd)
lul_hdcMem = CreateCompatibleDC(lul_hdc)
lul_hBitmap = CreateCompatibleBitmap(lul_hdc, aul_width, aul_height)
If lul_hBitmap <> 0 Then    // Copy the bitmap to memory location    SelectObject(lul_hdcMem, lul_hBitmap)   BitBlt(lul_hdcMem, 0, 0, aul_width, aul_height, &                        lul_hdc, aul_xpos, aul_ypos, SRCCOPY)    // try to store the bitmap into a blob so we can save it    lstr_Info.bmiHeader.biSize = 40    // Get the bitmapinfo    If GetDIBits(lul_hdcMem, lul_hBitmap, 0, aul_height, &                            0, lstr_Info, DIB_RGB_COLORS) > 0 Then        lul_pixels = lstr_Info.bmiHeader.biBitCount        lstr_Info.bmiColors[lul_pixels] = 0                lblb_bitmap = Blob(Space(lstr_Info.bmiHeader.biSizeImage/2))        // get the actual bits        GetDIBits(lul_hdcMem, lul_hBitmap, 0, aul_height, &                            lblb_bitmap, lstr_Info, DIB_RGB_COLORS)         // create a bitmap header        lstr_Header.bfType = BITMAPTYPE        lstr_Header.bfSize = lstr_Info.bmiHeader.biSizeImage        lstr_Header.bfOffBits = 54 + (lul_pixels * 4)        // copy the header structure to a blob        lblb_header = Blob(Space(14/2))        CopyBitmapFileHeader(lblb_header, lstr_Header, 14)        // copy the info structure to a blob        lblb_Info = Blob(Space((40  + lul_pixels * 4)/2))        CopyBitmapInfo(lblb_Info, lstr_Info, 40 + lul_pixels * 4)        // add all together and we have a window bitmap in a blob        lblb_bitmap = lblb_header + lblb_info + lblb_bitmap    End If
End If
// paste bitmap to clipboard
If ab_clipboard Then    If OpenClipboard(aul_hWnd) Then        EmptyClipboard()        SetClipboardData(CF_BITMAP, lul_hBitmap)        CloseClipboard()    Else        MessageBox("OpenClipboard Failed", of_GetLastError())    End If
End If
// Clean up handles
DeleteDC(lul_hdcMem)
ReleaseDC(aul_hWnd, lul_hdc)
Return lblb_bitmap

Viewing all articles
Browse latest Browse all 2935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>