How to Handle BIDisp Mouse Events in Mapping and SelectImageArea Modes
If an application uses more than one display object (BiDisp.ocx control) a mouse event could be a request to handle the get focus, on click, mouse down, or mouse up events. This doesn’t cause any problems if the Mapping property is set to false, and the SelectImageArea property is also set to false. In this case the user can use the event handler functions to handle the previously mentioned events. If either the Mapping or SelectImageArea properties is set to true, then the control handles these events and the user cannot catch them.
One of the easiest workarounds is the following:
The critical properties of the controls (Mapping and SelectImageArea) could be contained in global variables. If a control loses the focus, you can set these properties to false. In this case the user can handle the mouse events and when a control gets the focus again one can set the properties using the global variables.
So, you can set these properties to false when a LostFocus event is generated and set these properties to true when a GotFocus event is generated as you can see in the following VB.NET sample:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' DIB handler
Dim hDib As Long
' display settings
BIDisp1.ScaleMode = BIDISPLib.enumScaleMode.tifsmNoScale
BIDisp1.ScrollBars = BIDISPLib.enumScrollBars.tifsbBoth
BIDisp2.ScaleMode = BIDISPLib.enumScaleMode.tifsmNoScale
BIDisp2.ScrollBars = BIDISPLib.enumScrollBars.tifsbBoth
' load the tiff file
hDib = BITiff1.LoadTiffIntoDIB("test.tif", 0, False)
BIDisp1.hDib = hDib
BIDisp2.hDib = hDib
' set Mapping mode
BIDisp1.Mapping = False
BIDisp2.Mapping = False
End Sub
Private Sub BIDisp1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles BIDisp1.GotFocus
' set Mapping mode
BIDisp1.Mapping = True
End Sub
Private Sub BIDisp1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles BIDisp1.LostFocus
' set Mapping mode
BIDisp1.Mapping = False
End Sub
…
End Class
This sample contains a form (Form1) with two BiDisp (BiDisp1, BiDisp2) and a BiTiff (BiTiff1) controls. It references just for the Mapping property, but handling of the SelectImageArea property is the same. The implementation of the BIDisp2_GotFocus and the BIDisp2_LostFocus event handler functions are the same as the implementation of the BIDisp1_GotFocus and the BIDisp1_LostFocus functions.