Error message closing AutoCAD with ACCONT.ARX dockable container

Discussion in 'AutoCAD' started by Robert Plummer, Sep 10, 2004.

  1. I am just venturing into the realm of dockable containers in AutoCAD.
    Following the example in the documentation, I loaded the
    docktest.testcontrol routine included. I updated the control to work in ADT
    2004. When I run the control, it works as expected, however, if I close ADT
    without destroying the control, I get the following error message.

    Unhandled Exception C0000005 (Access Violation Reading 0x8ea12e9) at address
    8EA12E9h

    Did I miss something in building the control? Here is the base code for the
    control.


    (simple control)
    'Dim WithEvents dockContainer As AcadDockableContainer3
    Implements IRetrieveDockableContainer2
    Private Sub IRetrieveDockableContainer2_SetDockContainer(ByVal newVal As
    AC_CONT.AcadDockableContainer2)
    newVal.EnableDockPositions = acDockAny

    Dim rect(0 To 3) As Integer
    rect(0) = 50
    rect(1) = 50
    rect(2) = 500
    rect(3) = 100

    newVal.SetPreferredDockPosition acFloating, rect

    End Sub
     
    Robert Plummer, Sep 10, 2004
    #1
  2. It has nothing to do with your base code. If I remember correctly, the
    documentation for the testcontrol is wrong - think it was trying to
    retrieve a reference to the host session of AutoCAD which isn't required
    and would bomb on close. Here is the skeleton of the control code:

    Option Explicit
    '+--Interface to the dockable container
    Private WithEvents dockContainer As AcadDockableContainer3
    Implements IRetrieveDockableContainer2

    Private cadHwnd As Long

    Private Sub UserControl_Show()
    'Grab its handle
    cadHwnd = dockContainer.Application.ActiveDocument.hWnd
    'Change the caption
    SetCaption dockContainer, "Test Container"
    End Sub

    Private Sub IRetrieveDockableContainer2_SetDockContainer(ByVal newVal As
    AC_CONT.IAcadDockableContainer2)
    Set dockContainer = newVal
    dockContainer.EnableDockPositions = acDockLeft + acDockRight
    Dim rect(0 To 3) As Integer
    rect(0) = 50 ' left
    rect(1) = 50 ' top
    rect(2) = 225 ' right
    rect(3) = 225 ' bottom
    dockContainer.SetPreferredDockPosition acDockRight, rect
    End Sub

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 10, 2004
    #2
  3. Okay. You lost me a little here. I tried the code below and got the same
    results. Am I doing something wrong?
     
    Robert Plummer, Sep 11, 2004
    #3
  4. When I destroy the container on terminating the contol, it seems to work.
    Is this a reasonable approach?

    Private Sub UserControl_Terminate()

    dockContainer.Destroy

    End Sub
     
    Robert Plummer, Sep 11, 2004
    #4
  5. BTW, thanks a million!
     
    Robert Plummer, Sep 11, 2004
    #5
  6. If you want, email your code to me and I'll look at it. What I was saying
    was the example you are/were using has a reference to AcadApplication
    within either the control's code or the module that contains your code. The
    sample did a GetObject call [if I remember correctly] that is not required
    and will give the error message you are describing. As for destroying the
    container, it is not necessary as you can see in my code, I don't do it. If
    it is properly implemented, it will be destroyed whenever AutoCAD
    terminates.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 11, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.