GetRgnHandle example for C++ 5.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;
long SavedRegion;
ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL,
                 IID_ILEADRasterProcess, (void**)&pRasterProc);
// Initialize the variables that we will manipulate to simulate mouse coordinates.
OffsetX = m_LEADRasterView1.GetRaster().GetBitmapWidth() / 8;
OffsetY = m_LEADRasterView1.GetRaster().GetBitmapHeight() / 6;
// Create an elliptical region.
m_LEADRasterView1.GetRaster().SetRgnEllipse(OffsetX, OffsetY, OffsetX, OffsetY, L_RGN_SET);
// Save a copy of the region.
SavedRegion = m_LEADRasterView1.GetRaster().GetRgnHandle();
// Add the saved region to the bitmap, offsetting it so that we can see it.
m_LEADRasterView1.GetRaster().SetRgnHandle(SavedRegion, OffsetX, OffsetY, L_RGN_OR);
// Delete the saved region.
m_LEADRasterView1.GetRaster().DeleteRgnHandle(SavedRegion);
// Fill the bitmap region with blue.
pRasterProc->Fill(m_LEADRasterView1.GetRaster(), RGB(0, 0, 255));
// Free the bitmap region.
m_LEADRasterView1.GetRaster().FreeRgn();
// Repaint the image so that we can see how the image was updated.
m_LEADRasterView1.ForceRepaint();
pRasterProc->Release();