UpdateMagGlassFromHandle Example for C++ 5.0 and later
BOOL CSampleDlg::OnInitDialog()
{
.
.
.
bLeftButton = false;
m_LeadRasterView.SetEnableMethodErrors(false);
m_pRasterIO->Load(m_LeadRasterView.GetRaster(),"Sample1.cmp ",0,0,1);
m_pRasterIO->Load(m_LeadRasterView2.GetRaster(),"Sample2.cmp ",0,0,1);
m_LeadRasterView.SetMagGlassFlags(MAGGLASS_MANUAL_UPDATE);
// Starting the Magnifying Glass
m_LeadRasterView.StartMagGlass(100, 100, 400, RGB(255, 0, 0), RGB(128, 128, 128), false, 1, false, CROSSHAIR_FINE, true, true);
// Updating the Magnifying Glass bitmap of 1st control with bitmap of the
// 2nd control that has the same width and height.
m_LeadRasterView.UpdateMagGlassFromHandle(m_LeadRasterView2. GetRaster().GetBitmap(), true);
hMagGlassCursor = LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDC_MAGGLASS_CURSOR));
.
.
.
}
void CSampleDlg::OnMagGlassCursorLeadrasterview1()
{
// Check if the left button is not down and the Magnifying Glass is started
if (!(bLeftButton) && (m_LeadRasterView.GetHasMagGlass()))
::SetCursor(hMagGlassCursor);
}
void CSampleDlg::OnMouseDownLeadrasterview1(short Button, short Shift, float x, float y)
{
int nRet;
CString szMsg;
// Check if this is a left button and the Magnifying Glass is started
if (Button != 1 || !( m_LeadRasterView.GetHasMagGlass()))
return;
// Move the Magnifying Glass to the hit position
nRet = m_LeadRasterView.SetMagGlassPos((float) x, (float) y);
if (nRet != 0)
{
szMsg.Format(TEXT("Error while displaying Magnifying Glass, Error: %d"), nRet);
AfxMessageBox(szMsg);
return;
}
// Show the Magnifying Glass
nRet = m_LeadRasterView.ShowMagGlass(true);
if (nRet != 0)
{
szMsg.Format(TEXT("Error while displaying Magnifying Glass, Error: %d"), nRet);
AfxMessageBox(szMsg);
return;
}
// Left button is currently pressed
bLeftButton = true;
// Hide the cursor
::ShowCursor(false);
}
void CSampleDlg::OnMouseMoveLeadrasterview1(short Button, short Shift, float x, float y)
{
int nRet;
CString szMsg;
// Check if this is a left button and the Magnifying Glass is started
if (Button != 1 || !( m_LeadRasterView.GetHasMagGlass()))
return;
// Move the Magnifying Glass to the mouse position
nRet = m_LeadRasterView.SetMagGlassPos((float) x, (float) y);
if (nRet != 0)
{
szMsg.Format(TEXT("Error while Moving Magnifying Glass, Error: %d"), nRet);
AfxMessageBox(szMsg);
}
}
void CSampleDlg::OnMouseUpLeadrasterview1(short Button, short Shift, float x, float y)
{
int nRet;
CString szMsg;
// Check if this is a left button and the Magnifying Glass is started
if (Button != 1 || !( m_LeadRasterView.GetHasMagGlass()))
return;
// Show the Magnifying Glass
nRet = m_LeadRasterView.ShowMagGlass(false);
if (nRet != 0)
{
szMsg.Format(TEXT("Error while Hiding Magnifying Glass, Error: %d"), nRet);
AfxMessageBox(szMsg);
}
// Left button is released
bLeftButton = true;
// Show the cursor
::ShowCursor(true);
}