"neuman" wrote in message
news:f100ee8.1@WebX.maYIadrTaRb...
> Hi.
> I just started with vb.net. I tried your class and it worked but got an
error after I closed Acad.
Can you give me a few more details? I didn't seem to have
any problem after closing Acad.
> I too am curios about the question of events. is this
> true that the form handles all of the events even if
> we don't want to see them?
No. That's not true at all.
AcadXForm doesn't handle any AutoCAD events itself, and it
doesn't introduce any additional overhead into the event
sinking process.
When you add an event handler to one of the AutoCAD events
using the IDE, AcadXForm adds the event to the AcadApplication
object that it connects to, so you are actually adding your
event handler directly to the AcadApplication object, not the
form.
When your event handlers are fired, they're being called
directly by the AcadApplication object, not by the form.
This scheme constitutes 0 overhead in terms of events, and
the only events that are handled are the ones you write event
handlers for, and add to the form's event delgates.
AcadXForm maintains its own private delegates for each
AutoCAD event, but these are never fired. The reason it
does this, is so that if you disconnnect from one instance
of AutoCAD, and then reconnect to another instance, the
Form can remove the event handlers from the old instance,
and add them to the new instance of AutoCAD, *without*
requring you to do anything.
Normally, the IDE-generated code that adds events handlers to
a form member (like a Button or ComboBox) is called in the
form's constructor.
Of course, that would not work in cases where the object that
you want to add events to is not static and does not exist when
the form is created (as is the case with the AcadApplication
object), so I concocted this scheme, whereby I expose AutoCAD's
events as "fake" events of the form ("fake", because the form
never fires them itself). The reason I do this, is so that I
can keep track of what handlers you have added/removed for each
AutoCAD event, and dyanmically remove/add them from/to each
instance of AutoCAD that the form connects to.
So for example, if you run the application and connect to a
running copy of AutoCAD, and sink its events, then close that
copy of AutoCAD; restart another one; and reconnect the form
to the new instance of AutoCAD, your event handlers will
continue to be fired by the new AutoCAD instance, because the
form automatically adds the event handlers to the new instance
when it establishes the connection to it.
If you were doing everything "by hand', then when you connnect
to a different instance of AutoCAD, you would have to manually
add your event handlers to it. With AcadXForm, you don't have
to do that, because AcadXForm does this for you.