Available in the LEADTOOLS Imaging toolkit. |
GetFloaterHandle example for C++ 4.0 and later
The following is an alternative way of coding the PasteFloaterBtn button's click procedure in Outlining, Dragging, and Pasting a Region. This alternative uses the GetFloaterHandle and SetRgnHandle methods to specify the mask for the paste. It also shows how to use the HasRgn, FloaterWidth, and FloaterHeight properties.
void CTutorDlg::OnPastefloater()
{
// Variable for the Combine operation.
long MyOp;
// Variable for the saved region.
OLE_HANDLE SavedRgn;
// Variables for the client area coordinates.
float LCRgnX, LCRgnY , LCRgnWidth, LCRgnHeight;
// Variables for the bitmap coordinates.
float LBRgnX, LBRgnY , LBRgnWidth, LBRgnHeight;
// Exit this routine if there is no region.
if (m_Lead1.GetHasRgn() == FALSE) return;
// Save the region that is in the floater.
SavedRgn = m_Lead1.GetFloaterHandle();
// Get the floater into another bitmap
m_Lead2.SetScaleMode(m_Lead1.GetScaleMode());
m_Lead2.SetBitmap(m_Lead1.GetFloater());
// Get the floater's client coordinates into local variables.
LCRgnX = m_Lead1.GetFloaterDstLeft();
LCRgnY = m_Lead1.GetFloaterDstTop();
LCRgnWidth = m_Lead1.GetFloaterDstWidth();
LCRgnHeight = m_Lead1.GetFloaterDstHeight();
// Translate the client coordinates to bitmap coordinates.
LBRgnX = ((LCRgnX - m_Lead1.GetDstLeft()) / ZoomFactorX) + m_Lead1.GetSrcLeft();
LBRgnY = ((LCRgnY - m_Lead1.GetDstTop()) / ZoomFactorY) + m_Lead1.GetSrcTop();
LBRgnWidth = m_Lead1.GetFloaterWidth();
LBRgnHeight = m_Lead1.GetFloaterHeight();
// Delete the floater.
m_Lead1.SetFloaterVisible(FALSE);
m_Lead1.SetFloater(0);
// Set the saved region to use as a mask for the Combine method.
m_Lead1.SetRgnHandle(SavedRgn, LBRgnX, LBRgnY, L_RGN_SET);
// Use the Combine method to paste the Lead2 bitmap into the Lead1 bitmap.
MyOp = CB_OP_ADD + CB_DST_0; // Operation flags for a simple paste.
m_Lead1.Combine(LBRgnX, LBRgnY, LBRgnWidth, LBRgnHeight,
m_Lead2.GetBitmap(), 0.0f, 0.0f, MyOp);
// Repaint the part of the client area that has changed.
m_Lead1.RepaintRect(LCRgnX, LCRgnY, LCRgnWidth, LCRgnHeight, FALSE);
// Free the region.
m_Lead1.FreeRgn();
// Delete the region handle.
m_Lead1.DeleteRgnHandle(SavedRgn);
}