AnsweredAssumed Answered

Disable or Reset a tool/button

Question asked by lmwood on Jul 1, 2013
Latest reply on Jul 2, 2013 by lmwood
Hi I am converting vb to vb.net COM session not add in... I have made add ins and never had this problem but for some reason the tool will not reset when the quit button is enabled the forms all close but the tool cross hair is still active.  I have tried every method I could find including .close/exit.application closed the forms but nothing to avail any suggestions would be much appreciated. Below is the function that is connected to the quit button and closes the forms only. I have been able to dispose it but then it would give me an error that you could not recreate something that has been previous disposed.. which is fine and the button and cross hairs are still there.


Protected Overrides Sub Finalize()
        MyBase.Finalize()
        'MyBase.OnMouseMove()
        MyBase.Deactivate()
    End Sub

I was hoping there was a function like this that I could call within the quit to finalize the session and reset the tool.

Thanks again! :confused:

Public Sub Quit_PI_Session()          Dim frmCollection As System.Windows.Forms.FormCollection         Dim frm As System.Windows.Forms.Form         Dim countFrm As Integer         Dim frmArr(2) As Object         Dim frmName As String          On Error GoTo ErrorHandler          'Reset global session variables         dblFrameLength = 0         dblFrameWidth = 0         intRollNumber = 0         intVRollNumber = 0         intRRollNumber = 0         intLRollNumber = 0         intFrameNumber = 0         intMethodListIndex = 0         intPhotoIndexListIndex = 0         intUnitsListIndex = 0         intNewFramesCheckboxCounter = 0         intFramesShapefileNamesCounter = 0         strPhotoIndexShapefileName = ""         strFramesShapefileName = ""          'End the current session         'Unload frmMethods         'Unload(frmRollFrame)'vb6         'Unload(frmRollFrameControls)'vb6         'Unload(frmPhotoIndex) 'vb6          frmCollection = System.Windows.Forms.Application.OpenForms          countFrm = frmCollection.Count - 1         For value As Integer = 0 To countFrm             frmArr(value) = frmCollection.Item(value)         Next          For value As Integer = 0 To frmArr.Length - 1             'frmArr(value).Hide()              'frmArr(value).Close()             'frmArr(value).Dispose()         Next          myFrmFrameFootPrinter.Close()         myFrmRollFrame.Close()         myFrmRollFrameControls.Close()          myFrmFrameFootPrinter = New frmFrameFootPrinter         myFrmRollFrame = New frmRollFrame         myFrmRollFrameControls = New frmRollFrameControls         myFrmRollFrameControls = Nothing          'myFrmFrameFootPrinter.Dispose()         'myFrmRollFrame.Dispose()         'myFrmRollFrameControls.Dispose()          Debug.Print("Closed all forms")          Exit Sub  'This message just happens when you move the mouse over and over again if this is enabled  'Public Overrides Sub OnMouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer)     ''.NET deactivate tool     'If myFrmFrameFootPrinter.Visible = False Then     ' MsgBox("MyBase Deactivate")       'MyBase.Deactivate()     'MyBase.m_enabled = False      'End If End Sub  Private Sub cmdEndSession_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEndSession.Click          'Reset global variables and Quit Photo Index Frame processing         Call Quit_PI_Session()          ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown()         'MyBase.m_deactivate = True         'MyBase.Close()         ' MyBase.Activate()         'MyBase.ResetMouseEventArgs()            'Application.Exit()         'Close()         'Environment.Exit(0)         'createPhotoFrames.Exit()         'm_application.Visible = False                   ' The user wants to exit the application. Close everything down.         'Application.Exit()       End Sub 

Outcomes