Throw that code away and start over.
Show only one form, and each time the user switches documents, update that
form to show the data related to the newly activated document.
The code you posted will not and cannot work, and no one here is going to be
willing to untangle that mess to the extent needed to tell what's wrong with
it.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010
http://www.acadxtabs.com
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
wrote in message news:6285729@discussion.autodesk.com...
I have the following code running everytime I am making a windows active
It is loading a form (formaCSF) that display the global coordinate system(
autocad map ) and other variables
It is working fine.
I want to add to it an sub that will run everytime a document is closed or
autocad is closed or is loosing the focus(by opening another drawing or
switching with control+tab)
I don't know how to do it.
Can somebody point me in the right direction?
Thanks a lot
Public Class AutoLoad
Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
Public Sub Initialize() Implements IExtensionApplication.Initialize
AddHandler
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.DocumentBecameCurrent,
AddressOf Global1
End Sub
Public Sub Terminate() Implements IExtensionApplication.Terminate
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
Public Sub Global1()
Try
MsgBox(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Name)
Dim i As Integer = 0
Dim frm As Forma_CSF
Dim CSF As Double
Dim Inaltimea1 As Integer
Dim Proiectia1 As String
For Each frm In System.Windows.Forms.Application.OpenForms
i = i + 1
Next
Dim Current1 As Autodesk.Gis.Map.MapApplication
Current1 =
Autodesk.Gis.Map.HostMapApplicationServices.Application
Dim Proiect1 As Autodesk.Gis.Map.Project.ProjectModel
Proiect1 = Current1.ActiveProject
Proiectia1 = Proiect1.Projection.ToString
If Proiectia1 = "" Then
Proiectia1 = "NO CoordSys"
End If
CSF =
Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("USERR1")
If CSF = 0 Then CSF = 1
Inaltimea1 =
Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("USERI1")
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("FILEDIA",
1)
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("PLINETYPE",
2)
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("GEOMARKERVISIBILITY",
0)
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("EDGEMODE",
1)
Select Case i
Case 0
Dim Forma1 As New Forma_CSF
Forma1.Label1.Text = Proiectia1
Forma1.Label2.Text = "C.S.F. = " & CSF.ToString
Forma1.Label3.Text = "Scale = 1:" & Inaltimea1.ToString
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(Forma1)
Case 1
For Each frm In
System.Windows.Forms.Application.OpenForms
frm.Label1.Text = Proiectia1
frm.Label2.Text = "C.S.F. = " & CSF.ToString
frm.Label3.Text = "Scale = 1:" & Inaltimea1.ToString
Exit For
Next
Case Else
Exit Sub
End Select
Catch Ex As Exception
MsgBox(Ex.Message)
End Try
End Sub
End Class