Hide form select object

Discussion in 'AutoCAD' started by MP, Feb 17, 2005.

  1. MP

    MP Guest

    Hi all,
    Simple question - sure ive seen it discussed but couldn't find anything on
    google just now.
    show form, click command button, hide form, select object, return to form,
    use object.

    '(oEnt is declared at form level)
    'in command button
    Private Sub cmdPick_Click()
    SelectTarget
    End Sub

    'sub called by above button click
    Private Sub SelectTarget()
    Dim basePoint(0 To 2) As Double

    'this works
    Me.Hide

    'this sometimes works(from ide)sometimes i have to manually get acad focus
    ThisDrawing.Application.Visible = True

    'this works
    'will put error code here when get the basics working
    ThisDrawing.Utility.GetEntity oEnt, basePoint, "Select an object"

    'this works
    lblTarget.Caption = "Object: " & oEnt.ObjectName & vbCrLf & _
    "Layer: " & oEnt.Layer

    'this works (form comes back)
    Me.Show

    'this never runs - nothing after me.show happens
    If oEnt Is Nothing Then
    lblRead.Caption = "nOTHING"
    Else
    lblRead.Caption = "Got oEnt: " & oEnt.ObjectName
    End If

    End Sub

    if i move me.show to last line in sub the last if statement works

    so does me.show always have to be last line in any sub like this?
    why is that?
    That would seem to mean after getting my object i can't do any further
    processing -
    without hitting another command button or something...
    I know that's not right but don't know what I'm missing.

    Thanks
    Mark
     
    MP, Feb 17, 2005
    #1
  2. MP

    ClementZheng Guest

    Try this:
    Me.Show vbModeless
     
    ClementZheng, Feb 17, 2005
    #2
  3. Hi

    I too am having trouble implementing modeless forms, stuck with the VBA
    version relevant to ACAD 2000 (not sure of the version number).

    Am I missing a reference somewhere or is it a limitation?
    I have done some digging and found the poss solution of writing a DLL in VB
    (not vba) that will expose this method to a new instance of the form called
    from VBA? I have followed the instructions but I think I missed something
    somewhere when it comes to implementing it.

    any ideas?
    Many thanks

    James
     
    James McDonald, Feb 17, 2005
    #3
  4. MP

    ClementZheng Guest

    Sorry to hear that.
     
    ClementZheng, Feb 18, 2005
    #4
  5. MP

    Mark Propst Guest

    Ok, I had tried that before with same results (but went back and saw I only
    had the modeless in the first call to .Show, not in a subsequent one in
    different place in code.
    So I tried it and sure enough, now the form returns even with .Show not the
    last line in the sub.
    However the form is now useless cause the textboxes won't take focus so you
    cant' enter anything.
    I remembered reading about this issue so looking through my archives I found
    this
    from a post by ron starz
    "Go to the Toolbar, right click, click Additional Controls then check
    AcFocusCtrl Class.
    No add the newly added control from the toolbar to your form.
    In the Initialize area add
    Me.AcFocusCtrl1.KeepFocus = true
    now the textbox keeps its focus.
    Thanks to Rich Binning for noting this."

    so i tried it and immediately I put the control on the form and everything
    vanished in an instant - control, form, vba, and autocad evaporated in an
    instant.

    I must really be doing something wrong here.
    Any way thanks for the response, back to google to see what the fix is.
    Mark
     
    Mark Propst, Feb 18, 2005
    #5
  6. MP

    Mark Propst Guest

    well, when I just added the control from Additional Controls it crashed acad
    immediately.
    If I add a reference to the type lib first and then add the control from
    additional controls, it seems to work so far.
    Thanks
    Mark
     
    Mark Propst, Feb 18, 2005
    #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.