Message 1 of 7
another event question

Not applicable
05-31-2002
10:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
from the help file:
Private Sub ACADApp_BeginFileDrop(ByVal FileName As String, Cancel As
Boolean)
' This example intercepts an Application BeginFileDrop event.
'
' This event is triggered when a drawing file is dragged into AutoCAD.
'
' To trigger this example event:
' 1) Make sure to run the example that initializes
' the public variable (named ACADApp) linked to this event.
'
' 2) Drag an AutoCAD drawing file into the AutoCAD application from
either
' the Windows Desktop or Windows Explorer
' Use the "Cancel" variable to stop the loading of the dragged file, and
the "FileName"
' variable to notifiy the user which file is about to be dragged in.
If MsgBox("AutoCAD is about to load " & FileName & vbCrLf & "Do you want
to continue loading this file?", vbYesNoCancel + vbQuestion) <> vbYes Then
Cancel = True
End If
End Sub
My question is this:
As I understand it at this point(which is not very much), assuming all
required subs and classes exist and are initialized or whatever is needed
for this sub to run, at the moment the user drags a file into acad window,
the acad application is going to 'call' this sub. The acad application is
going to pass two arguments to this sub, the first being a byval copy of the
file name and then the second being a variable named "Cancel".
Since the Cancel arg is byRef, when you set it to true in the sub it's
original value is changed.
question 1: So that means that in the context of this sub, Cancel is a
global variable that the acadapplication created behind the scenes when you
created an acadapp variable using the with events keyword. Is that correct?
Question 2: Then after you set the variable to true here in this sub, after
this sub has run apparently the acad application is waiting in the
background with baited breath, waiting to see what you set the value of this
second argument to, and then it uses that value in some invisible sub that
we don't see here and runs that sub (the continuewithfiledrop activity in
this case) and uses that global variable "cancel" as an argument in some
further activity it is considering (such as opening the dragged file). Is
that what's going on here?
So the creation and declaration of the variable Cancel is just something
built into autocad? and when an app is created with events then all of this
mysterious stuff is prepared in the background and used according to however
the events are coded into the autocad application.
I guess this seems like a stupid obvious question but since I don't
understand exactly what's going on in the background and which is not
mentioned in any documentation I have found, I'm having trouble figuring out
by logic alone how to set up events and use them and a lot of time is going
into reading the help and trying to read between the few lines and trying
trial and error trying to get anything beyond the very basic examples to
work.
anyway, as always the wisdom and insight of those of you who "KNOW" all this
stuff is greatly appreciated!!!
Mark
Private Sub ACADApp_BeginFileDrop(ByVal FileName As String, Cancel As
Boolean)
' This example intercepts an Application BeginFileDrop event.
'
' This event is triggered when a drawing file is dragged into AutoCAD.
'
' To trigger this example event:
' 1) Make sure to run the example that initializes
' the public variable (named ACADApp) linked to this event.
'
' 2) Drag an AutoCAD drawing file into the AutoCAD application from
either
' the Windows Desktop or Windows Explorer
' Use the "Cancel" variable to stop the loading of the dragged file, and
the "FileName"
' variable to notifiy the user which file is about to be dragged in.
If MsgBox("AutoCAD is about to load " & FileName & vbCrLf & "Do you want
to continue loading this file?", vbYesNoCancel + vbQuestion) <> vbYes Then
Cancel = True
End If
End Sub
My question is this:
As I understand it at this point(which is not very much), assuming all
required subs and classes exist and are initialized or whatever is needed
for this sub to run, at the moment the user drags a file into acad window,
the acad application is going to 'call' this sub. The acad application is
going to pass two arguments to this sub, the first being a byval copy of the
file name and then the second being a variable named "Cancel".
Since the Cancel arg is byRef, when you set it to true in the sub it's
original value is changed.
question 1: So that means that in the context of this sub, Cancel is a
global variable that the acadapplication created behind the scenes when you
created an acadapp variable using the with events keyword. Is that correct?
Question 2: Then after you set the variable to true here in this sub, after
this sub has run apparently the acad application is waiting in the
background with baited breath, waiting to see what you set the value of this
second argument to, and then it uses that value in some invisible sub that
we don't see here and runs that sub (the continuewithfiledrop activity in
this case) and uses that global variable "cancel" as an argument in some
further activity it is considering (such as opening the dragged file). Is
that what's going on here?
So the creation and declaration of the variable Cancel is just something
built into autocad? and when an app is created with events then all of this
mysterious stuff is prepared in the background and used according to however
the events are coded into the autocad application.
I guess this seems like a stupid obvious question but since I don't
understand exactly what's going on in the background and which is not
mentioned in any documentation I have found, I'm having trouble figuring out
by logic alone how to set up events and use them and a lot of time is going
into reading the help and trying to read between the few lines and trying
trial and error trying to get anything beyond the very basic examples to
work.
anyway, as always the wisdom and insight of those of you who "KNOW" all this
stuff is greatly appreciated!!!
Mark