AnsweredAssumed Answered

HELP: Problems setting mouse cursor for AddIn tool

Question asked by Alderian on Jun 4, 2013
Latest reply on Jun 5, 2013 by Alderian
Hi everyone. Looking for a little help. I'm re-developing some VBA Macros into an ArcDesktop AddIn. I have a [Tool] coded that's used to select the point on the map used as the focal point for a report. The function of this works fine, with the user clicking the map to place a graphic on the map, and holding down CTRL+click to actually place and define the point (with graphic).

What I'm trying to do now is finesse the application a little, by changing the mouse pointer (to a custom pointer) when the tool is selected, and this is where I have the problem. First of all, I've tried the mouse pointer source as a PNG, an ICO, and a CUR. The latest attempt involved dropping the color-depth down to 24-bit and I was about to try 1-bit.

Code-wise, I've tried

        Dim curIcon As System.Object = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromIcon(myIcon)         appCursor.SetCursor(curIcon)

which has had mixed results, the latest taking the 24-bit pointer and displaying it as 1-bit, but is also non-contextual, so outside the map window the cursor remains.

I've also tried some code with Overriding the cursor property of the tool returning the current handle of the bitmap/icon/cursor:

            Dim m_Cursor As New System.Windows.Forms.Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName.Name & ".Marker24b.cur"))             If Not m_Cursor Is Nothing Then                 intptrCursor = m_Cursor.Handle                 System.Windows.Forms.Application.DoEvents()             End If


    Public Overloads ReadOnly Property cursor() As Integer         Get             Return intptrCursor.ToInt32()         End Get     End Property

But none of it seems to work correctly. It probably doesn't help that I'm also using OnKeyDown and OnKeyUp to detect the user pressing the CTRL key, changing the mouse pointer to indicate the difference in actions.

Please, any advice greatly welcome.

p.s. If anyone out there is producing PDF's I would advise taking a look at MigraDoc, which I've used in this project to create a document starting with a map, followed by tabular data representing what's on the map.