I'm still a bit of a dunce when it comes to using BitBlt - it's the next thing on my list of things to learn about. However, I was confused when I tried to use a snippet of code from VBWorld. It's found at http://www.vbsquare.com/tips/tip276.html, but I've copied it out below to save you the trouble of going there!
in the code on the webpage it saidCode:Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Const SRCCOPY = &HCC0020 Private Const SRCAND = &H8800C6 Private Const SRCINVERT = &H660046 Private Sub Form_Load() Dim DeskhWnd As Long, DeskDC As Long DeskhWnd& = GetDesktopWindow() DeskDC& = GetDC(DeskhWnd&) picMain.ScaleMode = vbPixels BitBlt picMain.hDC, 0&, 0&, picMain.ScaleWidth, picMain.ScaleHeight, DeskDC&, 0&, 0&, SRCCOPY End Sub
but I've tried changing the Form1.hDC to picMain.hDC to get the app to put an image of the desktop into a picture box instead of onto the form, but it won't! It just keeps the picture box looking plain and gray. Is there anyone who can point me in the right direction???Code:BitBlt Form1.hDC, 0&, 0&, Screen.Width, Screen.Height, DeskDC&, 0&, 0&, SRCCOPY




Reply With Quote