I found this post that has an example of trapping the return key in a list box:
http://www.planetsquires.com/protect/forum/index.php?topic=1738.msg14516#msg14516 (http://www.planetsquires.com/protect/forum/index.php?topic=1738.msg14516#msg14516)
That doesn't seem to work with the FireTextBox. It appears those messages aren't being sent by the control.
There is no simple way to do this with the FireTextBox. The best solution would be for me to add notifications from the FireTextBox that will be sent to the parent application. This would allow the programmer to act on certain messages (eg. handling the Return key) and then return a value to the FireTextBox to indicate that the user handled the key press so never mind handling it again.
The FireText box is actually two windows. The parent window and a child window with the child window being the actual edit control (which is subclassed).
Okay.
Many of the applications that I write are applications that drive test equipement. For these programs it is typical to type in a value and then hit return to apply the new value.
For Example, here is that custom frequency grid control that I have been working on in FF3.
(https://www.planetsquires.com/protect/forum/proxy.php?request=http%3A%2F%2Fwww.festus440.happypalm.com%2Ffgrid.jpg&hash=52d2cad281d9d929fb37192ed0889037b733a835)
In the VB version, the control is masked in the keypress event and a value is checked and then applied after hitting return or when the control loses focus.
I would prefer not to process these numbers while the user is typing them in, or having a separate button to apply the new values.
In searching the PB forums I see examples where people subclass controls and there is also a macro that uses a hook in a callback function of a textbox. Is there a way to implement any of these techniques in Firefly so I could also trap the return key?
I thought that you wanted to use the FireTextBox (which is a little harder because of the nature of it). You can use a regular TextBox control without any trouble. Actually, in FireFly it is pretty much a breeze because FireFly already subclasses the control for you. You can essentially take the code that you posted above for the ListBox and use it for the TextBox.
'--------------------------------------------------------------------------------
Function FORM1_TEXT1_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
Select Case wMsg
Case %WM_GETDLGCODE
Function = %DLGC_WANTALLKEYS
Exit Function
Case %WM_CHAR
If wParam = %VK_RETURN Then
MsgBox "ENTER key pressed"
End If
End Select
End Function
I wanted to use the FireTextBox because of the handy built in mask feature ;D
I hear ya. :) I'll try to get the additional functionality in the FireTextBox.
Hi Bob,
I have modified the FireTextBox control to fire a notification message whenever %WM_CHAR, %WM_KEYDOWN or %WM_KEYUP is pressed. You can respond to the message and if you action it then you can return %TRUE from the function to prevent the FireTextBox from continuing to process the key.
Copy the attached files into your existing FireTextBox custom control folder.
The following code will give you an idea of how to deal with responding to this message.
'--------------------------------------------------------------------------------
Function FORM1_FIRETEXTBOX1_FIRETEXTBOX_MSG_KEYPRESS( ControlIndex As Long, _
hWndForm As Dword, _
hWndControl As Dword, _
idTextControl As Long, _
pKeyPressNotify As Dword _
) As Long
Local pKey As FIRETEXTBOX_KEYPRESS Ptr
' Assign the incoming notification pointer
pKey = pKeyPressNotify
If (@pKey.nWinMsg = %WM_CHAR) And _
(@pKey.nKeyPress = %VK_RETURN) Then
' We will process the key here
? "ENTER pressed"
' Cancel the FireTextBox from processing the key
Function = %TRUE
End If
End Function
Paul,
That is great!
Thanks,
Bob
Would anyone have time to make a little demo program to Show how you can use FireTextBox to trap for Various Key presses such as Enter, ESC, FunctionKeys, Alt-Key combinations?