Unicode Controls & Classes for VB6 - Version 4

clsDIBSection.CloneFromHdc Method

Selects the image contained in the given Device Context and copies it to the new internal Device Context

Syntax
Public Sub CloneFromHdc (ByVal lHdc As Long, _
Optional ByVal bPP As eBppType = bpp_24, _
Optional ByRef cPal As clsPalette = Nothing, _
Optional ByVal lSrcLeft As Long = 0, _
Optional ByVal lSrcTop As Long = 0, _
Optional ByVal lSrcWidth As Long = -1, _
Optional ByVal lSrcHeight As Long = -1, _
Optional ByVal eRop As RasterOpConstants = vbSrcCopy)
Parameters
Parameter Description
ByVal lHdc As Long The source Device Context
Optional ByVal bPP As eBppType = bpp_24 The desired resolution
Optional ByRef cPal As clsPalette = Nothing The palette (optional)
Optional ByVal lSrcLeft As Long = 0 Specifies the x-coordinate of the rectangle's upper-left corner.
Optional ByVal lSrcTop As Long = 0 Specifies the y-coordinate of the rectangle's upper-left corner.
Optional ByVal lSrcWidth As Long = -1 Specifies the width of the rectangle
Optional ByVal lSrcHeight As Long = -1 Specifies the height of the rectangle
Optional ByVal eRop As RasterOpConstants = vbSrcCopy Type of copy
Remarks
In this sample we'll color our form in red
Option Explicit

Private Sub Form_Click()

Dim oDib As New clsDIBSection
oDib.CloneFromHdc Me.Hdc

Dim oWrap As New clsCommonWrapper
oWrap.DrawRectCoords oDib.Hdc, 0, 0, oDib.Width, oDib.Height, vbRed, True

oDib.PaintPicture Me.Hdc

End Sub