Accont12, Jorge's Dockable Container control

Discussion in 'AutoCAD' started by Maksim Sestic, Feb 2, 2004.

  1. Anybody knows a good example of how to control AcadDockableContainer
    (accont12.arx version by Jorge Lopez) from VBA (out of ACAD)? I did write
    some OCX controls in VB showing and managing a dockable container in ACAD,
    but I'd like to gain a control over it through VBA once it's loaded in
    memory.

    Any ideas?

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Feb 2, 2004
    #1
  2. An OCX is a complete unit of code. What would be the point in having VBA
    manage the container as opposed to the OCX itself?

    --
    There are 10 kinds of people. Those who understand binary and those who
    don't.

    http://code.acadx.com
    (Pull the pin to reply)
     
    Frank Oquendo, Feb 2, 2004
    #2
  3. You can use the AcadDockableContainers object from
    VBA to access and manage dockable containers, and
    get pointers to the hosted controls (I routinely
    use this from LISP to access control properties and
    methods).

    Specific examples require specifics on what exactly
    you want to do.
     
    Tony Tanzillo, Feb 2, 2004
    #3
  4. In my case, I need to launch the dockable container via VBA using
    SendCommand "DC"... and then run custom method from OCX named "RefreshMe".
    This second part (launching desired Public Sub of OCX from within VBA) seems
    a bit confusing to me. I guess I'll need to use Application.GetObject.....
    somehow but there's no specific explanation how exactly.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Feb 3, 2004
    #4
  5. You don't have to use the DC command to launch a
    dockable container (probably won't work since your
    VBA code isn't going to wait for the control to
    be loaded).

    You can do this, but you must have "accont.arx"
    loaded first:

    const szProgId = "AutoCAD.AcadDockableContainers"

    Dim Containers As AcadDockableContainers
    Set Containers = AcadApplication.GetInterfaceObject(szProgId)
    Containers.Add("YourLib.YourControl")

    That's essentially the same as using the DC command to
    launch a dockable container.

    Methods of the hosted OCX can be called from VBA like so:

    Dim DockClient As AcadDockableContainer3
    Set DockClient = Containers("YourLib.YourControl")
    Dim ContainedControl as Object
    Set ContainedControl = DockClient.Control
    ContainedControl.RefreshMe ....
     
    Tony Tanzillo, Feb 3, 2004
    #5
  6. Thanks a lot, Tony, this bothers me ever since Accont.arx showed up. This
    piece of code is what is really missing in Jorge's accompanying
    documentation, it would have probably saved me hundreds of hours "rewriting"
    functions from VBA to VB. This is also an explanation to Frenk who asked why
    bothering with VBA as OCX should deal with ACAD for itself - well, there are
    obvious reasons in my specific case:

    a) Rewriting code from ready-made VBA functions to VB (OCX), lots of
    redundant stuff...
    b) I need to show a list of (specific) blocks in my DockableContainer, to
    reflect the current state from the ACAD. It works for the first time I
    launch the control, but if user switches the container off and inserts new
    block, and then switches container again on - it will not refresh to reflect
    the current state of elements within ACAD (container's OnShow event launches
    only the first time it's loaded into memory). Maybe I'm missing something...

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Feb 4, 2004
    #6
  7. Tony,

    The example you've sent has a bug in the last line:

    Const szProgId = "AutoCAD.AcadDockableContainers"
    Dim Containers As AcadDockableContainers
    Set Containers = AcadApplication.GetInterfaceObject(szProgId) <---- bug
    reported


    VBA reports "Problem in loading application", which I suspect is the
    "AutoCAD" set in szProgId constant. I have accont.arx (v1.2) loaded and
    accont.tlb referenced within VBA, all of that running under Autodesk Map 5.
    Do you have any idea what an app name should be? I also tried with
    "AC_CONT.AcadDockableContainers" and "ACCONT.AcadDockableContainers" but
    without success.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Feb 4, 2004
    #7
  8. As one who contributed significant amounts of my own
    time to the Dockable Container, what really bugs the
    h*ll outta me, are people that look a gift horse in
    the mouth.
     
    Tony Tanzillo, Feb 4, 2004
    #8
  9. In my post, I clearly stated that ACCONT.ARX
    must be loaded first.
     
    Tony Tanzillo, Feb 4, 2004
    #9
  10. I loaded the ARX first, but not from the same place where TLB was stored (I
    had two copies of accont.arx and accompanying TLBs). I removed one of them
    and re-referenced the type library within VBA project. Now it works
    perfectly and many thanks for that.

    I have two additional questions on accont.arx (feel free to ignore them, you
    helped enough already):

    a) How to use dockContainer events in VB, like On_Float? The XXX are
    pointing to the control name I'm missing:
    Private Sub XXX_OnFloat()
    .....
    End Sub

    Should it point to name of control, UserControl itself or dockContainer?

    b) When SetPreferredDockingPosition is different that acFloating (when
    docked), then I'm unable to assign the initial width of dockContainer (it's
    much wider than needed). As there's no way to programmatically change the
    width of dockControl (Width and Height properties are read-only), I tried to
    SetPreferredDockingPosition to Float with predefined Rectangle (rect)
    coordinates, and then to immediatelly dock it. It didn't work either.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Feb 5, 2004
    #10
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.