Unicode Controls & Classes for VB6 - Version 4

clsMEMDC Class

This class permits you to manage an API Device Context in a safe way and provides conversion functions for VB6.
Similar to the [clsDIBSection] class but uses a Windows Bitmap inside
This class can only create images with the same resolution of the screen

Enums
Name Description
eMemDcBkMode Background Mode
Events
Name Description
Properties
Name Type Description
BkColor (Long) Gets or sets the background color of the internal Device Context
BkMode (eMemDcBkMode) Gets or sets the Background mode of the internal Device Context
Icon (Picture) Creates a standard Picture object from the internal image (in ICON format)
Picture (Picture) Creates a standard Picture object from the internal image (in Bitmap format)
Methods
Name Type Description
CloneFromHBmp Creates a bitmap from another bitmap handle, use PictureBox.Picture.Handle if you use VB6 controls
CloneFromHdc Selects the image contained in the given Device Context and copies it to the new internal Device Context
CreateDC Creates an image with a specified size (in pixels) and assign it to an internal Device context so you can easily use Windows drawing function on it
Destroy Frees used resources, called automatically when the class terminates or a new value is assigned using [CloneFromDib], [CloneFromHBmp], [CloneFromHdc], [CreateDC]
DrawBackColor Clear the internal image with a specified color
hBmp (Long) Returns the handle of the internal bitmap object
hDC (Long) Returns the handle of the internal Device Context
Height (Long) Returns the height of the internal image (in pixels)
PaintPicture Draws the internal image to the specified Device Context
ReleasehBmp (Long) Returns the internal bitmap handle and leave the user the responsability to Delete it ([clsCommonWrapper.DeleteObject]) when useless
After this call internal references to this object are deleted
ResizeAdaptDC Resizes the internal image stretching it
ResizeCutDC Resizes the internal image cutting it (if the new size is smaller) or adding margins (if the new size is bigger)
Width (Long) Returns the width of the internal image (in pixels)
Remarks
CloneFromHBmp Sample
In this sample we'll countour an image
Option Explicit

Private Sub Form_Click()

Dim oDib As New clsMemDC
oDib.CloneFromHBmp Image1.Picture.Handle

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

oDib.PaintPicture Me.Hdc

End Sub


CloneFromHdc Sample
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