| Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 | 1. Taking a snapshot of the screen #1093 Posted by: 2003-09-24 07:13:41 | Hello everybody
Can someone help me ? I need to take a snapshot of the screen. I know I have to use an API function, but I don't know how to do that, and I don't even know which API function to use ...
Thanks | 2. Re: Taking a snapshot of the screen #1094 Posted by: 2003-09-26 17:57:08 | This code was posted long ago by ... someone
' Simple full-screen capture utility $TYPECHECK ON $INCLUDE "RAPIDQ.INC"
CONST SRCCOPY = &HCC0020 CONST SRCPAINT = &HEE0086 CONST SRCAND = &H8800C6 CONST SRCINVERT = &H6600460 CONST SRCERASE = &H1100A6 CONST NOTSRCCOPY = &H330008 CONST NOTSRCERASE = &H1100A6 CONST MERGECOPY = &HC000CA CONST MERGEPAINT = &HBB0226 CONST PATCOPY = &HF00021 CONST PATPAINT = &HFB0009 CONST PATINVERT = &H5A0049 CONST DSTINVERT = &H550009 CONST BLACKNESS = &H000042 CONST WHITENESS = &HFF0062
DECLARE FUNCTION SetActiveWindow LIB "USER32" ALIAS "SetActiveWindow" (hWnd AS INTEGER) AS INTEGER DECLARE FUNCTION GetDC LIB "USER32" ALIAS "GetDC" (hWnd AS INTEGER) AS INTEGER DECLARE FUNCTION ReleaseDC LIB "USER32" ALIAS "ReleaseDC" (hWnd AS INTEGER, hDC AS INTEGER) AS INTEGER DECLARE FUNCTION BitBlt LIB "GDI32" ALIAS "BitBlt" _ (BYREF hDC AS INTEGER, nXDest AS INTEGER, nYDest AS INTEGER, _ nWidth AS INTEGER, nHeight AS INTEGER, hdcSrc AS INTEGER, _ nXSrc AS INTEGER, nYSrc AS INTEGER, dwRop AS INTEGER) AS INTEGER
DIM DC AS INTEGER DIM Bitmap AS QBITMAP
Bitmap.Width = Screen.Width Bitmap.Height = Screen.Height Bitmap.PixelFormat = pf24bit '-- Adjust as needed
SetActiveWindow(0) DC = GetDC(0) '-- You might want to check the return value of BitBlt, if 0, then it failed BitBlt(Bitmap.Handle, 0, 0, Screen.Width, Screen.Height, DC, 0, 0, SrcCopy) ReleaseDC(0,DC)
Bitmap.SaveToFile("CAPTURE.BMP")
-----------------------------------------------------
Attached to Yahooo RQ msg 9808 by "Jonathan Boles" <mousewithglasses@y...>
Const CCHDEVICENAME = 32 Const CCHFORMNAME = 32
Type DEVMODE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Long dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type
Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE) As Long Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal dwRop As Long) As Long
dim Bitmap as qbitmap, DeskhWnd as long, DeskDC as long
DeskhWnd=GetDesktopWindow() DeskDC = CreateDC("DISPLAY", "", "", DevThing) Bitmap.Height=Screen.Height Bitmap.Width=Screen.Width BitBlt(Bitmap.Handle,1,1,Screen.Width,Screen.Height,DeskDC,1,1,&HCC0020) Bitmap.SaveToFile("screenshot.bmp") ---------------------------------------------------- I tried none of them !
Jacques | 3. Re: Taking a snapshot of the screen #1098 Posted by: 2003-09-30 00:18:14 | Well, thanks pal !
The first code was provided by William Yu, but it doesn't seem to work ... I've tried it in many computers, and never succeeded to compile ...
But the second one works perfectly, thanks a lot, I owe you one ! | Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
|
|