Change ComboBox Focus

Discussion in 'AutoCAD' started by Paul Richardson, Oct 29, 2004.

  1. I have a Form who's "ShowModal" property
    is set to false. How can I change the focus
    from the Acad command line to a ComboBox
    on the Form so user can enter a value.

    I tried using the SetFocus property of
    the ComboBox and it's control frame
    with no luck.

    TFYT,
    Paul
     
    Paul Richardson, Oct 29, 2004
    #1
  2. Paul Richardson

    Mark Propst Guest

    Hi Paul,
    No one to the rescue yet eh?
    I set a watch on the thread cause when I saw the question I tried it and
    sure enough you can use the mouse to scroll and select but not type in the
    combobox.
    I've never tried a nonmodal so know nothing about how to handle it or even
    why one would want to...just cause I haven't done enough yet to find a need
    for that feature.

    Have you by chance tried the vb groups?
    For straight vb questions (not necessarily autocad specific) there's quite
    a bit of traffic out there.
    microsoft.public.vb.general.discussion is one that has some amazingly
    knowlegable and quickresponding gurus actively lurking - but you probably
    knew that.
    also microsoft.public.vb.winapi for all those pesky little api questions
    Good luck and I await with interest to see the answer.

    Mark
     
    Mark Propst, Oct 29, 2004
    #2
  3. Hi Mark, No luck. I ended up leaving it
    Modal for now and placed the operations
    for the Form in a loop so the user
    doensn't have to keep going back
    and fourth to said form unless they
    need to change the value for the
    operation.
    Thanks
    Paul
     
    Paul Richardson, Oct 30, 2004
    #3
  4. Paul Richardson

    AKS Guest

    This may help or it may not. I use a command button on a form to toggle its state between modal and modeless. Perhaps you can do the same. The user would need to hit the button to put the form back to modal. That task could also flop the focus where you want it. Then your action button, whatever it is, could switch the form back to modeless so that the user can continue working in the dwg until he or she needs to revisit the form.
     
    AKS, Oct 31, 2004
    #4
  5. Paul Richardson

    GTVic Guest

    You could try the SetActiveWindow and GetActiveWindows functions. Perhaps the initial problem is that the dialog itself does not have focus.

    Make sure you use the function in the form activate event or you will get the wrong value.

    Private Declare Function GetActiveWindow Lib "user32" () As Long
    Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long

    Private Sub UserForm_Activate()
    Me_HWnd = GetActiveWindow
    End Sub
     
    GTVic, Oct 31, 2004
    #5
  6. I use a command button on a form to toggle its state between
    I tired that but couldn't find a property for *ShowModal*
    that could be toggled at runtime

    Was going to put a click event in the comboBox window
    to toggle Modal state..

    What property do you use to toggle?

    Thank You,
    Paul
     
    Paul Richardson, Oct 31, 2004
    #6
  7. Paul Richardson

    Tom Roberts Guest

    Hi Paul

    You need to place an instance of the acfocusctl on your form

    Right click on your toolbox in the VBA IDE and select addition controls
    Scroll down and select the AcFocusCtl class
    Drop an instance on your form and you problems should be solved.
    The control is invisible at runtime and there is nothing to set

    --
    Regards
    Tom Roberts
    __________________________
    MechWest Design & Drafting
    Perth, Western Australia
     
    Tom Roberts, Nov 1, 2004
    #7
  8. Paul Richardson

    AKS Guest

    For what its worth. cbFloat is the button name. FloatMode
    is a flag used to keep track of what operating mode the vba
    is supposed to be in.

    Private Sub cbFloat_Click()
    Select Case FloatMode ' if 0 is not floating, if 1 is floating
    Case 0 ' not floating, change to floating
    Me.Hide
    SetFloatCaps (0)
    FloatMode = 1 ' is floating
    ShowMe
    Case 1 ' is floating, change to not floating
    Me.Hide
    SetFloatCaps (1)
    FloatMode = 0 ' is not floating
    ShowMe
    End Select
    End Sub

    Private Sub SetFloatCaps(M As Integer)
    Select Case M
    Case 0
    Me.cbFloat.Caption = "Unfloat"
    ufPickTarget.Caption = "Command/Cycle"
    Case 1
    Me.cbFloat.Caption = "Float"
    ufPickTarget.Caption = "Keyboard Cycle Only"
    End Select
    End Sub

    Private Sub ShowMe()
    Select Case FloatMode
    Case 0
    Me.Show
    Case 1
    Me.Show vbModeless
    End Select
    End Sub
     
    AKS, Nov 1, 2004
    #8
  9. Thank you all, Sorry I haven't had time to
    investigate each. Middle of crunch time.
    I will post my solution when I have time
    to readdress.

    Paul
     
    Paul Richardson, Nov 4, 2004
    #9
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.