Unicode Controls & Classes for VB6 - Version 4

clsMEMDC.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 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 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 clsMemDC
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