Modal Form (VB6 DLL)

Discussion in 'AutoCAD' started by GTVic, Mar 14, 2005.

  1. GTVic

    GTVic Guest

    Here is the code in a form that is shown vbModal. See the problem in the comments:
    [pre]Private Sub Button_Click()
    Me.Hide
    AcadDoc.Utility.GetEntity SelectedObject, Point, vbCr + "Select a polyline: "
    Me.Show vbModal
    ' code down here does not get executed until the form is closed
    ' so I have to move it above the Me.Show line
    End Sub[/pre]
    Why this problem with the location of the code?

    More info...

    Have a dialog in a VB6 DLL that works fine in 2004/2005. In testing with AutoCAD 2006 an error message says that the form must be modal.

    So I made the form modal if the version# is > 16.1 so it can still be non-modal for 2004/2005. When I made it modal I saw the problem listed above.

    (since the 2006 beta is over and the NDA is released I hope it is ok to talk about this)
     
    GTVic, Mar 14, 2005
    #1
  2. That's the way a modal form is supposed to work.
    Once it´s loaded, your program will wait until the
    modal form is unloaded to continue. User input is locked
    for any other form in your program.

    We've had some quirks testing our software on 2006
    but this is normal for a beta. Need to wait for final release.
     
    Jorge Jimenez, Mar 15, 2005
    #2
  3. GTVic

    GTVic Guest

    I think you may have misunderstood. The code is all in the modal form - no separate program.

    The form is hidden to get user input on the AutoCAD screen and then re-shown. This occurs in the click event of a button on the form. Once the form is shown again the remainder of the code in the click event fails to run until the form exits.

    Greg
     
    GTVic, Mar 15, 2005
    #3
  4. Ok. I get it now.
    Yes that's the way to do it using a modal form

    What exactly is the code that is not executing after the me.show ??
     
    Jorge Jimenez, Mar 15, 2005
    #4
  5. From the VB6 Help:

    "When Show displays a modeless form, subsequent code is executed as it's
    encountered. When Show displays a modal form, no subsequent code is
    executed until the form is hidden or unloaded."

    Terry
     
    Terry W. Dotson, Mar 15, 2005
    #5
  6. How's the form loaded the first time around ??

    Are changing the mode after the me.hide ??
     
    Jorge Jimenez, Mar 15, 2005
    #6
  7. GTVic

    GTVic Guest

    The form is originally loaded as modal and reshown as modal. The code after the Show processes the data gathered during the hide. So the effect was as if the data was not gathered.
     
    GTVic, Mar 17, 2005
    #7
  8. GTVic

    GTVic Guest

    Thanks Terry - who would have thought to look it up in the help :) Switching back and forth from VB6 and VBA isn't fun. Lots of inconsistencies like this - wish they were more similar.
     
    GTVic, Mar 17, 2005
    #8
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.