I have been working on a screen capture routine. This is close (Its what I
am using for now), one big problem with this .... Direct X overlays &
Applications don't get captured. I wish there is a nice way to grab the
Screen, Menu Pop-up's, Cursors, & DirectX Overlays all in one shot (Oh, and
it needs to be fast).
If you have any suggestions they are much appreciated!
Thanks!
Public oBackground As System.Drawing. Bitmap
Public Sub CaptureScreen()
Dim hSDC, hMDC, hMDC2 As Integer
Dim hBMP, hBMPOld As Integer
Dim CurInf As CursorInfo
Dim CurPos As PointAPI
Dim FW As Integer 'Width
Dim FH As Integer 'Height
Try
'Source DC
hSDC = CreateDC("DISPL AY", "", "", "")
'Destination DC with transpairent windows
hMDC = CreateCompatibl eDC(hSDC)
'Screen Width
FW = GetDeviceCaps(h SDC, HORIZRES)
'Screen height
FH = GetDeviceCaps(h SDC, VERTRES)
hBMP = CreateCompatibl eBitmap(hSDC, FW, FH)
hBMPOld = SelectObject(hM DC, hBMP)
Call BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, RasterOperation s.SRCCOPY +
RasterOperation s.CAPTUREBLT)
Call DeleteDC(hSDC)
'get cursor information
CurInf.cbSize = Len(CurInf)
Call GetCursorInfo(C urInf)
If (CurInf.flags And CURSOR_SHOWING) Then
'Call GetCursorPos(Cu rPos)
Call DrawIconEx(hMDC , CurInf.ptScreen Pos.X, CurInf.ptScreen Pos.Y, _
CurInf.hCursor, 0, 0, 0, False, DI_NORMAL)
End If
Call SelectObject(hM DC, hBMPOld)
Call DeleteDC(hMDC)
oBackground = System.Drawing. Image.FromHbitm ap(New IntPtr(hBMP))
DeleteObject(hB MP)
DeleteObject(hB MPOld)
'Seems to be a memory hole in fromHbitmap ....
'Code gets SLOW when not GC.Collect ing ... wierd.
'GC.Collect() &&&
Catch ex As Exception
Debug.WriteLine ("General GDI ERROR: " & ex.Message.ToSt ring)
End Try
End Sub
' Constants - BitBlt.dwRop
Public Enum RasterOperation s
SRCCOPY = &HCC0020 ' Copies the source rectangle directly to the destination
rectangle.
SRCPAINT = &HEE0086 ' Combines the colors of the source and destination
rectangles by using the Boolean OR operator.
SRCAND = &H8800C6 ' Combines the colors of the source and destination
rectangles by using the Boolean AND operator.
SRCINVERT = &H660046 ' Combines the colors of the source and destination
rectangles by using the Boolean XOR operator.
SRCERASE = &H440328 ' Combines the inverted colors of the destination
rectangle with the colors of the source rectangle by using the Boolean AND
operator.
NOTSRCCOPY = &H330008 ' Copies the inverted source rectangle to the
destination.
NOTSRCERASE = &H1100A6 ' Combines the colors of the source and destination
rectangles by using the Boolean OR operator and then inverts the resultant
color.
MERGECOPY = &HC000CA ' Merges the colors of the source rectangle with the
brush currently selected in hdcDest, by using the Boolean AND operator.
MERGEPAINT = &HBB0226 ' Merges the colors of the inverted source rectangle
with the colors of the destination rectangle by using the Boolean OR
operator.
PATCOPY = &HF00021 ' Copies the brush currently selected in hdcDest, into
the destination bitmap.
PATPAINT = &HFB0A09 ' Combines the colors of the brush currently selected in
hdcDest, with the colors of the inverted source rectangle by using the
Boolean OR operator. The result of this operation is combined with the
colors of the destination rectangle by using the Boolean OR operator.
PATINVERT = &H5A0049 ' Combines the colors of the brush currently selected
in hdcDest, with the colors of the destination rectangle by using the
Boolean XOR operator.
DSTINVERT = &H550009 ' Inverts the destination rectangle.
BLACKNESS = &H42 ' Fills the destination rectangle using the color
associated with index 0 in the physical palette. (This color is black for
the default physical palette.)
WHITENESS = &HFF0062 ' Fills the destination rectangle using the color
associated with index 1 in the physical palette. (This color is white for
the default physical palette.)
NOMIRRORBITMAP = &H80000000 ' Windows 98, Windows 2000: Prevents the bitmap
from being mirrored.
CAPTUREBLT = &H40000000 ' Windows 98, Windows 2000: Includes any windows
that are layered on top of your window in the resulting image. By default,
the image only contains your window.
End Enum
"gregory_ma y" <None> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Does anyone know if anything is in the works to make DirectX work better
with .Net?
Thanks!