'In a separate module containing project scope variables and constants... Friend frm1 As Form1 ------------------------------------------------------------------- 'In the BaseCommand class "button"... Public Overrides Sub OnClick() If IsNothing(frm1) OrElse frm1.IsDisposed Then frm1 = New Form1 frm1.Show(New ModelessDialog(m_application.hWnd)) Else frm1.Show() End If End Sub ------------------------------------------------------------------- 'Then the form code itself... Public Class Form1 Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If e.CloseReason = Windows.Forms.CloseReason.UserClosing Then e.Cancel = True Me.Hide() End If End Sub End Class
'...in the COM class that inherits BaseCommand (i.e., a button on an ArcMap toolbar). Public Overrides Sub OnClick() Try 'Set pMxDoc and other variables used by multiple tools GetMxDocumentFromArcMap(m_application) 'Make sure there are maps and layers in the document If Not CheckFrames() Then Exit Sub 'create form and open it. If IsNothing(clsGlobals.frmTemplate) OrElse clsGlobals.frmTemplate.IsDisposed Then clsGlobals.frmTemplate = New TemplateForm(pMxDoc) SetWindowLong(clsGlobals.frmTemplate.Handle.ToInt32, GWL_HWNDPARENT, pApp.hWnd) clsGlobals.frmTemplate.Show() Else clsGlobals.frmTemplate.WindowState = FormWindowState.Normal clsGlobals.frmTemplate.BringToFront() End If Catch ex As Exception ExHandling(ex) End Try End Sub
Private Sub TemplateForm_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Disposed ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown() End Sub
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.