Using ESC to close a form

Discussion in 'AutoCAD' started by David Urban, Oct 26, 2004.

  1. David Urban

    David Urban Guest

    I have a program that uses a form for its interface and most of the
    autocad forms will allow the user to hit escape to close it (ie the
    layer manager box.) I think it would be simple but don't know how to do
    it.

    Thanks

    David Urban
     
    David Urban, Oct 26, 2004
    #1
  2. Put a CLOSE button on your form, and set its Cancel property to TRUE. Then
    put "Unload Me" in the button's click event. Hitting ESC while the form is
    up runs the click event of whichever button has Cancel=True (only one Cancel
    button allowed per form).

    HTH,
    James
     
    James Belshan, Oct 26, 2004
    #2
  3. David Urban

    Matt W Guest

    Or you could simply put "Unload Me" in the UserForm_KeyPress event.

    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    | Put a CLOSE button on your form, and set its Cancel property to TRUE.
    Then
    | put "Unload Me" in the button's click event. Hitting ESC while the form
    is
    | up runs the click event of whichever button has Cancel=True (only one
    Cancel
    | button allowed per form).
    |
    | HTH,
    | James
    |
    |
    | | > I have a program that uses a form for its interface and most of the
    | > autocad forms will allow the user to hit escape to close it (ie the
    | > layer manager box.) I think it would be simple but don't know how to do
    | > it.
    | >
    | > Thanks
    | >
    | > David Urban
    |
    |
     
    Matt W, Oct 26, 2004
    #3
  4. David Urban

    David Urban Guest

    Thanks for the help

    I was not able to get the form to work with the userform_Keypress
    because I had text boxes. It worked with putting the keypress in the
    text box form. It ended up putting a cancel button with the cancel
    property = True and send the button behind everything where it can't be
    seen. that works the best.

    Thanks for all of the help

    David
     
    David Urban, Oct 27, 2004
    #4
  5. David Urban

    AKS Guest

    You can leave the button in a visible portion of your form for editing purposes and then move the button behind something during form intialization. Moving it behind a listbox seems to work fine. I think you might want to take tab stop off the button.
     
    AKS, Oct 27, 2004
    #5
  6. Or set its visible property to false.
     
    Nathan Taylor, Oct 27, 2004
    #6
  7. David Urban

    wivory Guest

    I don't think you can "activate" it when it's invisible.

    Regards

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, Oct 28, 2004
    #7
  8. David, Somebody posted this for me
    a while back...Works great...if you'd
    like to try...gl Paul

    '@~~~~~~~General Declarations~~~~~~~@'
    'Lets user escape with ESC key...calls user32.dll..
    'part of all windows systems since 95
    Public Const VK_ESCAPE = &H1B
    Declare Function GetAsyncKeyState Lib "user32" _
    (ByVal vKey As Long) As Integer
    Public Function UserEscaped() As Boolean
    If GetAsyncKeyState(VK_ESCAPE) Then UserEscaped = True
    End Function

    'Possible call....

    If UserEscaped Then
    Err.Clear
    GoTo myExit' Cleans up and closes the program
    ElseIf Err.Number <> 0 Then
    Err.Clear
    GoTo Retry'Loop back to my getEntity call...
    Exit Sub
     
    Paul Richardson, Oct 28, 2004
    #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.