PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Haakon Birkeland on December 03, 2005, 08:40:29 PM

Title: Button Return key problem
Post by: Haakon Birkeland on December 03, 2005, 08:40:29 PM
I have a button that when it has the focus if I press the enter key it will act as if clicked on. When I use the mouse it works the way it is supposed to.

Function JOBFORM_SAVEBTN_CUSTOM ( _
                               ControlIndex  As Long,  _  ' index in Control Array
                               hWndForm      As Dword, _  ' handle of Form
                               hWndControl   As Dword, _  ' handle of Control
                               wMsg          As Long,  _  ' type of message
                               wParam        As Dword, _  ' first message parameter
                               lParam        As Long   _  ' second message parameter
                               ) As Long
If wMsg = %WM_GETDLGCODE And wParam = %VK_RETURN Then
JOBFORM_SAVEBTN_BN_CLICKED 0,HWND_JOBFORM,HWND_JOBFORM_SAVEBTN,IDC_JOBFORM_SAVEBTN
End If

End Function


What I want to do is eat the return key because when the next text control gets focus it processes as if the return key had just been pressed and tab over to the next control.

Bert
Title: Button Return key problem
Post by: TechSupport on December 04, 2005, 01:34:19 PM
Hi Bert,

I am trying to follow your logic process. I assume that in the BN_CLICKED message you are saving data and then setting the focus to a textbox (I guess in order to start the editing of a new record).

I think that if you break out of the CUSTOM message after calling the BN_CLICKED then "maybe" it should work:


If wMsg = %WM_GETDLGCODE And wParam = %VK_RETURN Then
     JOBFORM_SAVEBTN_BN_CLICKED 0,HWND_JOBFORM,HWND_JOBFORM_SAVEBTN,IDC_JOBFORM_SAVEBTN
     Function = %TRUE: Exit Function
End If
Title: Button Return key problem
Post by: Haakon Birkeland on December 04, 2005, 03:29:24 PM
your description is right. When I press Return I start editing a new record. The return key becomes associated with the textbox instead of the button. Your solution did not work.
Here is what the button clicked code has.

Function JOBFORM_SAVEBTN_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long
   Select Case FF_Control_GetText(HWND_JOBFORM_SAVEBTN)
       Case "Save"
           SaveButtonClicked                                
       Case "Reset"
           ResetButtonClicked                                
       Case "Insert"
           InsertButtonClicked                                
   End Select
  FF_Control_Disable HWND_JOBFORM_DELBTN   'delete button deactivated
FF_Control_SetFocus HWND_JOBFORM_JOBTXT 'go back to first field
   
End Function

'------------------------------------------------------------------------------------------------------------------------
Function JOBFORM_SAVEBTN_CUSTOM ( _
                               ControlIndex  As Long,  _  ' index in Control Array
                               hWndForm      As Dword, _  ' handle of Form
                               hWndControl   As Dword, _  ' handle of Control
                               wMsg          As Long,  _  ' type of message
                               wParam        As Dword, _  ' first message parameter
                               lParam        As Long   _  ' second message parameter
                               ) As Long
If wMsg = %WM_GETDLGCODE And wParam = %VK_RETURN Then
JOBFORM_SAVEBTN_BN_CLICKED 0,HWND_JOBFORM,HWND_JOBFORM_SAVEBTN,IDC_JOBFORM_SAVEBTN
Function = %True: Exit Function
End If

End Function

Title: Button Return key problem
Post by: TechSupport on December 05, 2005, 10:52:02 AM
Hi Bert,

I also assume that for each of your TextBoxes that you are advancing to the next field using the ENTER key. I made a very simple, quick and dirty, project with two textboxes and a Save button. I press ENTER and it advances through all of the controls wihtout any trouble (as far as I can see).

You may want to try downloading a recent version of the FireFly Engine just to see if it makes any difference (maybe I changed some code generation...).

http://www.planetsquires.com/files/FFengine.zip


Function JOBFORM_SAVEBTN_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long
 
   Select Case FF_Control_GetText(HWND_JOBFORM_SAVEBTN)
       Case "Save"
           'SaveButtonClicked                                
       Case "Reset"
           'ResetButtonClicked                                
       Case "Insert"
           'InsertButtonClicked                                
   End Select
   
   'FF_Control_Disable HWND_JOBFORM_DELBTN   'delete button deactivated
   FF_Control_SetFocus HWND_JOBFORM_JOBTXT 'go back to first field
   
End Function

'-----------------------------------------------------------------------------------
Function JOBFORM_SAVEBTN_CUSTOM ( _
                               ControlIndex  As Long,  _  ' index in Control Array
                               hWndForm      As Dword, _  ' handle of Form
                               hWndControl   As Dword, _  ' handle of Control
                               wMsg          As Long,  _  ' type of message
                               wParam        As Dword, _  ' first message parameter
                               lParam        As Long   _  ' second message parameter
                               ) As Long
 
  If wMsg = %WM_GETDLGCODE And wParam = %VK_RETURN Then
     JOBFORM_SAVEBTN_BN_CLICKED 0,HWND_JOBFORM,HWND_JOBFORM_SAVEBTN,IDC_JOBFORM_SAVEBTN
     Function = %True: Exit Function
  End If

End Function


'-----------------------------------------------------------------------------------
Function JOBFORM_JOBTXT_CUSTOM ( _
                              ControlIndex  As Long,  _  ' index in Control Array
                              hWndForm      As Dword, _  ' handle of Form
                              hWndControl   As Dword, _  ' handle of Control
                              wMsg          As Long,  _  ' type of message
                              wParam        As Dword, _  ' first message parameter
                              lParam        As Long   _  ' second message parameter
                              ) As Long

  If wMsg = %WM_GETDLGCODE And wParam = %VK_RETURN Then
     SetFocus HWND_JOBFORM_TEXT2
     Function = %True: Exit Function
  End If

End Function



'-----------------------------------------------------------------------------------
Function JOBFORM_TEXT2_CUSTOM ( _
                             ControlIndex  As Long,  _  ' index in Control Array
                             hWndForm      As Dword, _  ' handle of Form
                             hWndControl   As Dword, _  ' handle of Control
                             wMsg          As Long,  _  ' type of message
                             wParam        As Dword, _  ' first message parameter
                             lParam        As Long   _  ' second message parameter
                             ) As Long

  If wMsg = %WM_GETDLGCODE And wParam = %VK_RETURN Then
     SetFocus HWND_JOBFORM_SAVEBTN
     Function = %True: Exit Function
  End If

End Function
Title: Button Return key problem
Post by: Haakon Birkeland on December 05, 2005, 11:32:53 AM
Thanx.
Maybe my french gets in the way. As of now all the boxes are working properly with the return get. All I really want to do is eat the return key in the Save button CUSTOM event.
I have it working now by creating an invisible textbox which when it gets focus eats the return key and sends the focus back to the proper textbox. I just think this is a kludge way to do something. I just assume there was a way to just change the value of the key when I trap the return key in CUSTOM event.

Bert