make <ENTER> work like <TAB>

Started by Gary Stout, January 08, 2015, 09:40:52 PM

Previous topic - Next topic

Gary Stout

Petrus,

Something like this....(untested but I am using similar code for other purposes)


         Case %WM_KEYUP           
            If Msg.wParam = %VK_RETURN Then
              If GetParent(Msg.hWnd) = HWND_CONTRIBUTIONS Then               
                 FF_CloseForm (HWND_MAINFORM)   
              End If
            End If

David Kenny

Peter,

Gary's example is correct about how to do it.  Just replace the %VK_RETURN with %VK_ESCAPE.

But, as to where it should go, it depends on what you are trying to do. 

In Gary's case, it had to go in the pump hook because he was trying to get to the message early (before the editbox could do it's default behavior).

What I have discovered, by using a form with no controls, is that the Form itself doesn't get WM_ESCAPE messages (someone correct me if I am wrong).  So there is no one-place you can put your code to process the escape key in FF's "Breakout msg handler routines". So, this is another case where you should put it in FF_PUMPHOOK. That way, you won't have to check for Escape in each controls msg handler.

In some of my programs, the user can cancel an edit (of an editbox for instance) with the escape key.  So, I have a global edit_flag that is set and cleared when any control is gaining or loosing focus. In a case like that, the Escape handling routine in the pumphook would need to check to see if any fields are in edit mode (and changes have been made). If an edit is going on, it would not process the Escape key.

Petrus Vorster

In VB6 we had a keypreview function.
That i used so when the user pressed ESC he would close the form.
It was just a Case /End case in the keypreview directory. Very simple.

Keypresses works much faster on a tool you know well than the mouse.
So whatever form except main is currently open should close back to the form it was created from.

-Regards
Peter