以下程序可以将屏幕图片位图数据拷贝到内存环境中,然后进行处理。 不过我用getpixel写了个找色程序,好像比在屏幕设备中找色要慢,搞不懂,留着以后慢慢研究吧。
Dim hDCMemory As Long
Dim hBmp As Long
Dim hBmpPrev As Long
' Depending on the value of Client get the proper device context.
hDCSrc = hWndSrc
' Create a memory device context for the copy process.
hDCMemory = CreateCompatibleDC(hDCSrc)
' Create a bitmap and place it in the memory DC.
hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
hBmpPrev = SelectObject(hDCMemory, hBmp)
r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy)
hBmp = SelectObject(hDCMemory, hBmpPrev)
' Release the device context resources back to the system.
r = DeleteDC(hDCMemory)
r = ReleaseDC(hWndSrc, hDCSrc)