LEADTOOLS Windows Forms (Leadtools.WinForms assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
SetInteractiveModeCursor Method
See Also 
Leadtools.WinForms Namespace > RasterImageViewer Class : SetInteractiveModeCursor Method



interactiveMode
A RasterViewerInteractiveMode enumeration member that specifies the interactive mode to set the mouse cursors for.
idleCursor
A Cursor that defines the mouse cursor to use when the interactive mode is idle.
workingCursor
A Cursor that defines the mouse cursor to use when the interactive mode is working.
interactiveMode
A RasterViewerInteractiveMode enumeration member that specifies the interactive mode to set the mouse cursors for.
idleCursor
A Cursor that defines the mouse cursor to use when the interactive mode is idle.
workingCursor
A Cursor that defines the mouse cursor to use when the interactive mode is working.
Sets the mouse cursors associated with an interactive mode

Syntax

Visual Basic (Declaration) 
Public Sub SetInteractiveModeCursor( _
   ByVal interactiveMode As RasterViewerInteractiveMode, _
   ByVal idleCursor As Cursor, _
   ByVal workingCursor As Cursor _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterImageViewer
Dim interactiveMode As RasterViewerInteractiveMode
Dim idleCursor As Cursor
Dim workingCursor As Cursor
 
instance.SetInteractiveModeCursor(interactiveMode, idleCursor, workingCursor)
C# 
public void SetInteractiveModeCursor( 
   RasterViewerInteractiveMode interactiveMode,
   Cursor idleCursor,
   Cursor workingCursor
)
C++/CLI 
public:
void SetInteractiveModeCursor( 
   RasterViewerInteractiveMode interactiveMode,
   Cursor^ idleCursor,
   Cursor^ workingCursor
) 

Parameters

interactiveMode
A RasterViewerInteractiveMode enumeration member that specifies the interactive mode to set the mouse cursors for.
idleCursor
A Cursor that defines the mouse cursor to use when the interactive mode is idle.
workingCursor
A Cursor that defines the mouse cursor to use when the interactive mode is working.

Example

This example will change the cursors used in RasterViewerInteractiveMode.MagnifyGlass to be a cross when idle and an empty cursor when working.

Visual BasicCopy Code
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Private Class ICONINFO
   Public fIcon As Boolean
   Public xHotspot As Integer
   Public yHotspot As Integer
   Public hbmMask As IntPtr
   Public hbmColor As IntPtr
End Class
<DllImport("user32.dll")> _
Private Shared Function CreateIconIndirect(ByVal piconinfo As ICONINFO) As IntPtr
End Function

<DllImport("user32.dll")> _
Private Shared Function GetIconInfo(ByVal hIcon As IntPtr, <Out()> ByRef piconinfo As ICONINFO) As Boolean
End Function

<DllImport("user32.dll")> _
Private Shared Function DestroyIcon(ByVal handle As IntPtr) As Boolean
End Function

Private Sub SetInteractiveModeCursorExample(ByVal viewer As RasterImageViewer)
   Dim idleCursor As Cursor = Cursors.Cross
   Dim workingCursor As Cursor = Nothing

   ' Create an empty cursor to use when the magnifying glass is on
   ' Use the same size as the Cross cursor

   Using btmp As New Bitmap(idleCursor.Size.Width, idleCursor.Size.Height)
      Using g As Graphics = Graphics.FromImage(btmp)
         g.Clear(Color.Transparent)
      End Using

      Dim iconInfo As New ICONINFO()
      Dim hIcon As IntPtr = btmp.GetHicon()
      GetIconInfo(hIcon, iconInfo)
      iconInfo.xHotspot = btmp.Width \ 2
      iconInfo.yHotspot = btmp.Height \ 2
      iconInfo.fIcon = False

      Dim hCursor As IntPtr = CreateIconIndirect(iconInfo)
      workingCursor = New Cursor(hCursor)

      DestroyIcon(hIcon)
   End Using

   viewer.SetInteractiveModeCursor(RasterViewerInteractiveMode.MagnifyGlass, idleCursor, workingCursor)

   ' Not set the interactive mode to magnify glass
   viewer.InteractiveMode = RasterViewerInteractiveMode.MagnifyGlass
End Sub
C#Copy Code
[StructLayout(LayoutKind.Sequential, Pack = 1)]
private class ICONINFO
{
   public bool fIcon;
   public int xHotspot;
   public int yHotspot;
   public IntPtr hbmMask;
   public IntPtr hbmColor;
}
[DllImport("user32.dll")]
private static extern IntPtr CreateIconIndirect([Out] ICONINFO piconinfo);

[DllImport("user32.dll")]
private static extern bool GetIconInfo(IntPtr hIcon, [In, Out] ICONINFO piconinfo);

[DllImport("user32.dll")]
private extern static bool DestroyIcon(IntPtr handle);

private void SetInteractiveModeCursorExample(RasterImageViewer viewer)
{
   Cursor idleCursor = Cursors.Cross;
   Cursor workingCursor = null;

   // Create an empty cursor to use when the magnifying glass is on
   // Use the same size as the Cross cursor

   using(Bitmap btmp = new Bitmap(idleCursor.Size.Width, idleCursor.Size.Height))
   {
      using(Graphics g = Graphics.FromImage(btmp))
      {
         g.Clear(Color.Transparent);
      }

      ICONINFO iconInfo = new ICONINFO();
      IntPtr hIcon = btmp.GetHicon();
      GetIconInfo(hIcon, iconInfo);
      iconInfo.xHotspot = btmp.Width / 2;
      iconInfo.yHotspot = btmp.Height / 2;
      iconInfo.fIcon = false;

      IntPtr hCursor = CreateIconIndirect(iconInfo);
      workingCursor = new Cursor(hCursor);

      DestroyIcon(hIcon);
   }

   viewer.SetInteractiveModeCursor(RasterViewerInteractiveMode.MagnifyGlass, idleCursor, workingCursor);

   // Not set the interactive mode to magnify glass
   viewer.InteractiveMode = RasterViewerInteractiveMode.MagnifyGlass;
}

Remarks

Use this method to set different mouse cursors for each interactive mode used in this RasterImageViewer. A value of null (Nothing in Visual Basic) for any of the cursors instructs the viewer to use the default cursor set in the Cursor property either by the designer or through code.

By default, all the interactive modes have a cursor value of null (Nothing in Visual Basic) and changing the interactive mode will not change the mouse cursor unless you call this method first to set the desired cursors to use.

The idle cursor is used when the interactive mode is not working, in other words, when the user has set the interactive mode to a value but has not clicked the mouse button to initiate it yet. The working cursor is used when the interactive mode is working, in other words, when the user has clicked and start dragging the mouse button.

Note that when you call this method, the current interactive mode will be canceled if it is working.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also