RefBitmap example for C++ 5.0 and later
void CDemoView::OnRefbitmap()
{
//This example demonstrates the RefBitmap property
//Assume that m_RasterView is a LEADRasterView OCX
ILEADRaster *pRaster;
HRESULT hr;
TCHAR szMsg[100];
hr = CoCreateInstance(
CLSID_LEADRaster,
NULL,
CLSCTX_ALL,
IID_ILEADRaster,
(void**)&pRaster);
ILEADRasterIO *pRasterIO;
hr = CoCreateInstance(
CLSID_LEADRasterIO,
NULL,
CLSCTX_ALL,
IID_ILEADRasterIO,
(void**)&pRasterIO);
//Load an image into MyRaster object
pRasterIO->Load (pRaster, "d:\\work\\images\\rgbw.bmp", 0, 0, 1);
wsprintf(szMsg, TEXT("pRaster->Bitmap should be non-zero: %x"), pRaster->Bitmap);
AfxMessageBox(szMsg);
//Have the LEADRasterView1 control "steal" the MyRaster bitmap
m_RasterView.GetRaster().SetRefBitmap(TRUE);
m_RasterView.GetRaster().SetBitmap(pRaster->Bitmap);
//The MyRaster Bitmap has been invalidated
wsprintf(szMsg, TEXT("pRaster->Bitmap should be zero: %x"), pRaster->Bitmap);
AfxMessageBox(szMsg);
pRaster->Release();
pRasterIO->Release();
}