PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Marc van Cauwenberghe on October 29, 2011, 01:35:32 PM

Title: esc to exit dialog (=currentwindow)
Post by: Marc van Cauwenberghe on October 29, 2011, 01:35:32 PM
Hi,

I know, pretty basic.
How does one catch the escape key to exit the dialog (= current window), the FF way.

Thanks for any answer.

Marc
Title: Re: esc to exit dialog (=currentwindow)
Post by: David Kenny on October 29, 2011, 08:02:35 PM
Marc,

Edit the properties of whichever button you would normally use to close your form (Ok, Cancel, etc.).  Set the Cancel option to True.  Then add the following code in the forms WM_COMMAND section:Function FORM1_WM_COMMAND ( _
                             hWndForm     As Dword, _  ' handle of Form
                             hWndControl  As Dword, _  ' handle of Control
                             wNotifyCode  As Long,  _  ' notification code
                             wID          As Long   _  ' item, control, or accelerator identifer
                             ) As Long
Select Case wID
Case IDC_FORM1_CMDOKCANCEL          ' Look for the IDC of the button that closes your form here
FF_CloseForm HWND_FORM1, %True   ' and close the form.
End Select
End Function

If you don't have/want a button to close your form, just use one and set it to not be visible.

David
Title: Re: esc to exit dialog (=currentwindow)
Post by: Marc van Cauwenberghe on October 30, 2011, 06:47:24 AM
Thanks David,

unfortunately, it did not work here.
First I use rrbuttons all the time and they do not have a CANCEL option.
I then added a default button to do what you said but the form with that button did not even show up. I' ll try to explain.
From FORM1 I show FORM2 (with cancel button) but I think it goes directly to the FORM2_WM_COMMAND and the FROM2 does not appear.

Any thoughts?
Marc
Title: Re: esc to exit dialog (=currentwindow)
Post by: Marc van Cauwenberghe on October 30, 2011, 07:43:24 AM
Maybe I shoud add that FORM2 has a TAB control.

Marc
Title: Re: esc to exit dialog (=currentwindow)
Post by: Paul Squires on October 30, 2011, 11:46:54 AM
Try adding something like this to your FF_PumpHook code:

   If IsWindow( HWND_FORM1 ) Then
      Select Case Msg.Message
   
         Case %WM_KEYUP
            If msg.wParam = %VK_ESCAPE Then
               msg.Message = %WM_NULL
               ? "escape pressed"
               FF_CloseForm HWND_FORM1
               Function = %FALSE
               Exit Function
            End If   
      End Select     
   End If


Title: Re: esc to exit dialog (=currentwindow)
Post by: Marc van Cauwenberghe on October 30, 2011, 12:24:26 PM
That did it.
Thanks Paul.

Have a nice sunday both of you.

Marc