Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / Taking a snapshot of the screen

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. 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
Message2. 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
Message3. 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 First 1 Last
掌柜推荐
 
 
¥287.00 ·
 
 
¥2,600.00 ·
 
 
¥289.00 ·
 
 
¥1,370.00 ·
 
 
¥289.00 ·
 
 
¥1,480.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0