Dll talk to calling form?

Discussion in 'AutoCAD' started by Mark Propst, May 1, 2004.

  1. Mark Propst

    Mark Propst Guest

    Hi,
    I cant' seem to get this to work.

    There's undoubtably a better way to do this, but what I'm trying is:

    vb6 exe launches a form
    the form init looks for running instance of acad
    if it finds it, it passes active doc ref to vb6dll to do some cleanup work
    on the doc

    since i think the form is out of process and the dll is in process, to save
    time, i thought that was what i wanted to do (use dll for the timeconsuming
    work).

    while the dll is working, i wanted to report back periodic progress for some
    kind of indication to the user that it's working and didn't just freeze up.

    one way was to update a label caption
    so i tried to pass the label object to a property of the dll class but got
    an error, cant pass objects blah blah

    so i tried to call the form lable from the dll by saying
    formname.labelname.caption = blah
    but the dll code doesn't recognize the formname as a variable

    so i tried to pass the form itself as the "calling owner" to a property of
    the dll class and that also didn't work(same error as with label)

    then i tried a sample i got off the net for a progress bar on a form but
    the sample works with a command button but I haven't figured out how to get
    the dll to show the form, calls in the dll to show the form seem to have no
    effect, no error, no form shown, no progress bar....

    any ideas on how to show a simple update of progress when a dll is doing the
    work but a form is the user interface for displaying the progress?

    seems like i should be able to figure this out on my own but after 2 days
    and nights of trying and searching google and trying various samples i still
    cant figure it out.

    tia
    Mark
     
    Mark Propst, May 1, 2004
    #1
  2. You need to expose an event on your ActiveX server
    in your dll, that fires periodically to give your
    out-of-process client a chance to update its UI.

    I don't know much about passing VB controls across
    process boundaries, but wouldn't be too suprised
    if trying to do that didn't work.
     
    Tony Tanzillo, May 2, 2004
    #2
  3. Mark Propst

    Mark Propst Guest

    I'll have to read up on exposing events.

    would that be like the dll having an invisible form with a timer on it, then
    calling a sub in the ui form every so often?
    for some reason the dll doesn't seem to see the form name as a variable that
    can be accessed.

    'or something to this effect?
    'time consuming sub in dll
    Private Sub LongSlowProcessInDll()
    lCount = 0
    'set progressbar max
    ScanProg.Max = oDoc.ModelSpace .Count
    ScanProg.Min = 0
    ScanProg.Cur = 0

    For Each oObj In oDoc.ModelSpace
    'do something
    CheckOut oObj
    lcount = lcount + 1

    'set current position of progress bar
    ScanProg.Cur = lCount

    'update to display change
    ScanProg.UpdateStatus

    'is this what allows it to go out and update the user interface form?
    DoEvents

    Next oObj

    bDoneScan = True
    ProgScan.Visible = False
    End sub
     
    Mark Propst, May 2, 2004
    #3
  4. Mark - No, not like an invisible form with a timer.

    Events are just like the ones AutoCAD exposes. I do
    not have much familiarity with exposing events in VB
    so I can't help you there.

    You want to fire the event every so often (once for
    each entity is probably too frequently), so you might
    do it once for every 10 entities or something like
    that. The event is handled by the form/client and
    it can update its UI, and call DoEvents to have the
    updates reflected on the screen.

    IOW, in the code below, where you have the call to
    DoEvents, you would replace that with the code that
    fires the event. The DoEvents call in your code is
    probably not doing anything, since its not being
    called from a form method.
     
    Tony Tanzillo, May 2, 2004
    #4
  5. Mark Propst

    Mark Propst Guest

    Thanks Tony,
    Now to assimilate and put to practice...
    Mark
     
    Mark Propst, May 2, 2004
    #5
  6. Try the VB Class Builder Addin. It can add events
    to an ActiveX object.
     
    Tony Tanzillo, May 3, 2004
    #6
  7. Mark Propst

    Mark Propst Guest

    Thanks I'll give it a try.
     
    Mark Propst, May 3, 2004
    #7
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.