GetFloaterHandle example for C++ Builder
This example 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.
//Note that ZoomFactorX, ZoomFactorY must be declared as a global variables, and
//have a correct data when you use this code.
//Declare the variable for the Combine operation.
long MyOp;
//Declare the variable for the saved region.
long SavedRgn;
//Declare the variables for the client area coordinates.
float LCRgnX, LCRgnY, LCRgnWidth, LCRgnHeight;
//Declare the variables for the bitmap coordinates.
float LBRgnX, LBRgnY, LBRgnWidth, LBRgnHeight;
LEADRasterProcess* pRasterProc= NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);
//Exit this routine if there is no region.
if (LEADRasterView1->Raster->HasRgn == false)
return;
//Save the region that is in the floater.
SavedRgn = LEADRasterView1->GetFloaterHandle ();
//Get the floater into another bitmap
LEADRasterView2->ScaleMode = LEADRasterView1->ScaleMode;
LEADRasterView2->Raster->RefBitmap = False;
LEADRasterView2->Raster->Bitmap = LEADRasterView1->Floater;
//Get the floater//s client coordinates into local variables.
LCRgnX = LEADRasterView1->FloaterDstLeft;
LCRgnY = LEADRasterView1->FloaterDstTop;
LCRgnWidth = LEADRasterView1->FloaterDstWidth;
LCRgnHeight = LEADRasterView1->FloaterDstHeight;
//Translate the client coordinates to bitmap coordinates.
LBRgnX = ((LCRgnX - LEADRasterView1->DstLeft) / ZoomFactorX) + LEADRasterView1->SrcLeft;
LBRgnY = ((LCRgnY - LEADRasterView1->DstTop) / ZoomFactorY) + LEADRasterView1->SrcTop;
LBRgnWidth = LEADRasterView1->FloaterWidth;
LBRgnHeight = LEADRasterView1->FloaterHeight;
//Delete the floater.
LEADRasterView1->FloaterVisible = False;
LEADRasterView1->Floater = 0;
//Set the saved region to use as a mask for the Combine method.
LEADRasterView1->Raster->SetRgnHandle (SavedRgn, LBRgnX, LBRgnY, L_RGN_SET);
//Use the Combine method to paste the LEADRasterView2 bitmap into the LEADRasterView1 bitmap.
MyOp = CB_OP_ADD + CB_DST_0; //Operation flags for a simple paste.
pRasterProc->Combine (LEADRasterView1->Raster,
LBRgnX, LBRgnY, LBRgnWidth, LBRgnHeight,
LEADRasterView2->Raster,
0, 0, (CombineConstants)MyOp);
//Repaint the part of the client area that has changed.
LEADRasterView1->RepaintRect (LCRgnX, LCRgnY, LCRgnWidth, LCRgnHeight, False);
//Free the region.
LEADRasterView1->Raster->FreeRgn ();
//Delete the region handle.
LEADRasterView1->Raster->DeleteRgnHandle (SavedRgn);
pRasterProc-> Release( );