Results 1 to 10 of 10

Thread: Can some please explain the difference between Userform_Activate and _Intitialize

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Posts
    6
    Location

    Can some please explain the difference between Userform_Activate and _Intitialize

    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

  2. #2
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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 .

  3. #3
    VBAX Regular
    Joined
    Feb 2007
    Posts
    6
    Location
    Thanks Tommy. I appreciate the insight.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,456
    Location
    Quote Originally Posted by Tommy
    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.

  5. #5
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Quote Originally Posted by xld
    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 with Acad VBA

  6. #6
    VBAX Regular
    Joined
    Feb 2007
    Posts
    6
    Location
    Correct, something like this.

    [VBA]
    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
    [/VBA]

  7. #7
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    What happens if the entity is not a polyline?
    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.

  8. #8
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    You mean you can not make a userform System Modal = False in AutoCAD?

  9. #9
    VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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.

    (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. But you sure can draw a pretty drawing!

  10. #10
    VBAX Newbie
    Joined
    Mar 2007
    Posts
    1
    Location
    Tommy, Could you come help me out when you get back from lunch?

    Kev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •