Available in the LEADTOOLS Imaging toolkit. |
GetFloaterHandle example for Visual Basic
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.
Private Sub PasteFloaterBtn_Click()
'Declare the variable for the Combine operation.
Dim MyOp As Long
'Declare the variable for the saved region.
Dim SavedRgn As Long
'Declare the variables for the client area coordinates.
Dim LCRgnX, LCRgnY , LCRgnWidth, LCRgnHeight
'Declare the variables for the bitmap coordinates.
Dim LBRgnX, LBRgnY , LBRgnWidth, LBRgnHeight
'Exit this routine if there is no region.
If Lead1.HasRgn = False Then Exit Sub
'Save the region that is in the floater.
SavedRgn = Lead1.GetFloaterHandle
'Get the floater into another bitmap
Lead2.ScaleMode = Lead1.ScaleMode
Lead2.Bitmap = Lead1.Floater
'Get the floater's client coordinates into local variables.
LCRgnX = Lead1.FloaterDstLeft
LCRgnY = Lead1.FloaterDstTop
LCRgnWidth = Lead1.FloaterDstWidth
LCRgnHeight = Lead1.FloaterDstHeight
'Translate the client coordinates to bitmap coordinates.
LBRgnX = ((LCRgnX - Lead1.DstLeft) / ZoomFactorX) + Lead1.SrcLeft
LBRgnY = ((LCRgnY - Lead1.DstTop) / ZoomFactorY) + Lead1.SrcTop
LBRgnWidth = Lead1.FloaterWidth
LBRgnHeight = Lead1.FloaterHeight
'Delete the floater.
Lead1.FloaterVisible = False
Lead1.Floater = 0
'Set the saved region to use as a mask for the Combine method.
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.
Lead1.Combine LBRgnX, LBRgnY, LBRgnWidth, LBRgnHeight, Lead2.Bitmap, 0, 0, MyOp
'Repaint the part of the client area that has changed.
Lead1.RepaintRect LCRgnX, LCRgnY, LCRgnWidth, LCRgnHeight, False
'Free the region.
Lead1.FreeRgn
'Delete the region handle.
Lead1.DeleteRgnHandle SavedRgn
End Sub