>> So I dont need to worry about multiple instances
>> of "MyApp" object being created.
Well, not quite.
The way it works is that if your command method is
non-static (not shared), as is the case in your code,
AutoCAD creates a seperate instance of your class,
for each open document. So, if there are 3 open
documents, there will be three instances of your
That may be what is leading you to think that VB is
automatically switching the events every time you
assign a non-static/shared member variable that has
the 'WithEvents', to another document.
In fact, what you don't realize is that there is more
than one instance of your class, and each of them is
being used with a different document, so it gives the
illusion that the event handlers are automatically
added to the document assigned to the variable each
time the variable's value is changed, but that's not
what's going on at all.
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
wrote in message news:firstname.lastname@example.org...
Yes, I have been wondering, and am unclear on when exactly "MyApp" is created. I would guess that NETLOAD does not create an instance of "MyApp". In order to execute the command method, an instance of "MyApp" is created... If thats the case then I would assume a second instance of "MyApp" is NOT created when the command is ran for a second time. So I dont need to worry about multiple instances of "MyApp" object being created. What about resetting mThisDrawing each time a new document becomes the active document? Will that make the same event handler work for the new active doc? (I guess I could do some tests to figure that out, but it sounds logical...) Am I on the right track here?