MagGlassOwnerDraw Example for C++ 5.0 and later

BOOL CAnnMagGlassDlg::OnInitDialog()
{
    .
    .
    .
    .
    HRESULT hr;
   
    m_pRasterIO = NULL;
    m_pRasterAnn = NULL;
   
    m_RasterView.GetRaster().UnlockSupport(L_SUPPORT_DOCUMENT,L_KEY_DOCUMENT);
   
    hr = CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL,
                            IID_ILEADRasterIO, (void**)&m_pRasterIO);
   
    if (FAILED (hr))
    {
       return FALSE;
    }
   
    hr = CoCreateInstance(CLSID_LEADRasterAnnotation, NULL, CLSCTX_ALL,
                            IID_ILEADRasterAnnotation, (void**)&m_pRasterAnn);
   
    if (FAILED (hr))
    {
       return FALSE;
    }
   
    m_pRasterIO->Load(m_RasterView.GetRaster(),"c:\\1.bmp",0,0,1);
   
    IDispatch *pDispatch=NULL;
    (m_RasterView.GetControlUnknown())->QueryInterface(IID_IDispatch, (void**)&pDispatch);
   
   
    m_pRasterAnn->PutAnnParentRasterView(pDispatch);
    m_pRasterAnn->AnnUserMode = ANN_USERMODE_DESIGN;
    m_pRasterAnn->AnnCreate(ANN_OBJECT_BUTTON, true, true);
   
    m_hObject = m_pRasterAnn->GetAnnObject();
   
    m_pRasterAnn->PutAnnRectHeight(m_hObject,100);
    m_pRasterAnn->PutAnnRectWidth(m_hObject,200);
    m_pRasterAnn->PutAnnRectLeft(m_hObject,50);
    m_pRasterAnn->PutAnnRectTop(m_hObject,50);
   
   
    return TRUE; // return TRUE unless you set the focus to a control
}

void CAnnMagGlassDlg::OnStartMagGlass()
{
    m_RasterView.SetEnableMagGlassDraw(true);
    m_pRasterAnn->PutAnnEnableMagGlass(true);
    m_RasterView.StartMagGlass(200, 200, 200, RGB(0, 0, 0),
                                     RGB(255, 255, 255), false, 1,
                                     false, CROSSHAIR_FINE, false, false);
}

 

void CAnnMagGlassDlg::OnStopMagGlass()
{
    m_RasterView.StopMagGlass();
    m_RasterView.SetEnableMagGlassDraw(false);
    m_pRasterAnn->PutAnnEnableMagGlass(false);
}
void CAnnMagGlassDlg::OnMagGlassOwnerDraw(long hWnd, long hMemDC, long lXPos, long lYPos, long lMagGlassTop, long lMagGlassLeft, long lMagGlassBottom, long lMagGlassRight)
{
    m_pRasterAnn->AnnMagGlass(hMemDC, lXPos, lYPos, 200, 200, 200);
}