GetRgnHandle example for C++ 4.0 and later

The following code creates a region, saves its handle and adds the saved region beside the current region.

// Declare local variables.
float OffsetX, OffsetY;
OLE_HANDLE SavedRegion;

// Initialize the variables that we will manipulate to simulate mouse coordinates.
OffsetX = m_Lead1.GetBitmapWidth() / 8;
OffsetY = m_Lead1.GetBitmapHeight() / 6;

// Create an elliptical region.
m_Lead1.SetRgnEllipse(OffsetX, OffsetY, OffsetX, OffsetY, L_RGN_SET);

// Save a copy of the region.
SavedRegion = m_Lead1.GetRgnHandle();

// Add the saved region to the bitmap, offsetting it so that we can see it.
m_Lead1.SetRgnHandle(SavedRegion, OffsetX, OffsetY, L_RGN_OR);

// Delete the saved region.
m_Lead1.DeleteRgnHandle(SavedRegion);

// Fill the bitmap region with blue.
m_Lead1.Fill(RGB(0, 0, 255));

// Free the bitmap region.
m_Lead1.FreeRgn();

// Repaint the image so that we can see how the image was updated.
m_Lead1.ForceRepaint();