DLL call

Discussion in 'AutoCAD' started by Sa Mite Samite, Aug 11, 2003.

  1. I'm having problem calling dialog based DLL made in VB5 and calling
    from AutoCAD 2000i (OS: windows 2000). Here is the project.
    It is very simple and for testing purpose only.
    I've tried to cover VB Variant (Array) and Collection types
    to see what type is actually converted <safearray...> in VB. I've tried to
    use
    vlax-vbVariant and vlax-vbString types to convert AutoLisp 'LIST type for
    the same porpuse too.
    Here is the project

    vb PROJECT called "ListBox"

    FORM called "frmListBox". With a single object on it
    LISTBOX called "List1"
    CLASS called "clsListBoxArr". With a single public function
    called "ListBoxArr" as

    Public Function ListBoxArr(arrItems As Variant)
    Dim frm As New frmListBox
    Dim Count As Integer

    With frm.List1
    For Count = 0 To UBound(arrItems)
    .AddItem arrItems(Count)
    Next
    .ListIndex = 0
    End With
    End Function


    CLASS called "clsListBoxColl". With a single public function
    called "ListBoxColl" as

    Public Function ListBoxColl(collItems As Collection)
    Dim frm As New frmListBox
    Dim Count As Integer

    With frm.List1
    For Count = 1 To collItems.Count
    .AddItem collItems(Count)
    Next
    .ListIndex = 0
    End With
    End Function

    Now from AutoCAD I'm calling both objects to see with one will work.

    Call 1: As array variant

    (setq AA (vlax-create-object "ListBox.clsListBoxArr"))
    (setq ref (list "ABC" "DEF" "GHI")
    vL (vlax-make-safearray vlax-vbVariant (cons 0 (length ref))) ;;; This
    is also a test to see which way
    sL (vlax-make-safearray vlax-vbString (cons 0 (length ref))) ;;;
    (vbVariant or vbString) will work
    i 0)
    (while (<= i (length ref))
    (setq xx (vlax-make-variant (nth i ref)))
    (vlax-safearray-put-element vL i xx)
    (vlax-safearray-put-element sL i xx)
    (setq i (1+ i)))
    (vlax-invoke AA 'ListBoxArr vL) ; error: ListBox: Type mismatch
    (vlax-invoke AA 'ListBoxArr sL) ; error: ListBox: Type mismatch

    Call 2: As collection

    (setq BB (vlax-create-object "ListBox.clsListBoxColl"))
    (setq ref (list "ABC" "DEF" "GHI")
    vL (vlax-make-safearray vlax-vbVariant (cons 0 (length ref))) ;;; This
    is also a test to see which way
    sL (vlax-make-safearray vlax-vbString (cons 0 (length ref))) ;;;
    (vbVariant or vbString) will work
    i 0)
    (while (<= i (length ref))
    (setq xx (vlax-make-variant (nth i ref)))
    (vlax-safearray-put-element vL i xx)
    (vlax-safearray-put-element sL i xx)
    (setq i (1+ i)))
    (vlax-invoke BB 'ListBoxColl vL) ; error: argument type mismatch:
    #<safearray...>
    (vlax-invoke BB 'ListBoxColl sL) ; error: argument type mismatch:
    #<safearray...>

    but there is no success at all with maximum options I tried to cover.
    Where I'm doing wrong? Can someone help me here?

    Thanks
     
    Sa Mite Samite, Aug 11, 2003
    #1
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.