PDA

View Full Version : Can some please explain the difference between Userform_Activate and _Intitialize



sdp777
02-13-2007, 12:57 PM
I am sure there are reasons for using one or both for specific functions. I have spent some time in the help file on AutoCAD's vba and I still dont really grasp it.

Thanks
Steven D. Papke

Tommy
02-13-2007, 06:05 PM
Intitialize is when the form is first loaded into memory, this occurs before the Activate event.

Activate gets the focus which means it is the form currently accepting input.

The activate event would be fired everytime you hide it to make a call to getpoints :).

sdp777
02-13-2007, 06:42 PM
Thanks Tommy. I appreciate the insight.

Bob Phillips
02-14-2007, 04:13 AM
The activate event would be fired everytime you hide it to make a call to getpoints :).

When you hide it? I don't think I have ever experienced that.

Another important thing to note is that Initialize happens before the form is painted, Activate after.

Tommy
02-14-2007, 08:50 AM
When you hide it? I don't think I have ever experienced that.

Another important thing to note is that Initialize happens before the form is painted, Activate after.

It's an Autocad thing. ex: When you want the user to select a group of lines, you have to hide the userform to allow the user to select, get a point... if the user is going to work on the screen interactivelly. It's one of the :banghead: with Acad VBA :devil2:

sdp777
02-14-2007, 08:55 AM
Correct, something like this.


Private Sub CommandButton1_Click()
Dim vPt As Variant, vObj As Object, vObjPt As Variant, pArea As Integer
AreaTest.hide
ThisDrawing.Utility.GetEntity vObj, vObjPt, vbLf + "Select polyline: "
Dim strfield As String
pArea = vObj.Area / 144
TextBox1.Text = pArea & " SQFT"
AreaTest.Show
End Sub

Tommy
02-14-2007, 11:55 AM
What happens if the entity is not a polyline?:doh:
It could be a circle, line, text, mtext ......

I prefer to use selection sets. I can filter out what I don't want to work on while allowing the user to select whatever they want to. The drawing order messes up the selection when the entities cross. This way I know the properties are actually there, reduces the chance of the user selecting things that don't apply. Yeah I know it's a pain, but it keeps me out of trouble every once in a while. :thumb

fumei
02-14-2007, 05:22 PM
You mean you can not make a userform System Modal = False in AutoCAD?

Tommy
02-14-2007, 06:03 PM
No, it seems to think that a document (drawing in this case) has to be active, it's called a space, they have tabs (sheets in Excel) for each "printed" view (paper space) and a model space which is where the drawing is. Each paper space is a different view/scale and/or print showing different information. Also most of the calls back to the app are selections, getpoints, etc where the form would need to be out of the way.:dunno

(I don't know why, I spent a day or 2 trying to figure out how to, then I find the news groups <sigh> same problem, same answer)

So in short modal doesn't work in Acad VBA.:wot But you sure can draw a pretty drawing! :thumb

UncleK
03-06-2007, 10:16 AM
Tommy, Could you come help me out when you get back from lunch?

Kev :sleuth: