Despite this limitation it is actually possible to detect an ENTER keypress with WM_KEYDOWN window message and the WINMSG event but ONLY if the EditTable is set to "Protected", i.e.

To trap the ENTER key we first need to tell OpenInsight that we want to be notified of any WM_KEYDOWN window messages that are sent to the EditTable by using the OpenInsight QUALIFY_EVENT message. This is normally done in the form's CREATE event:
0001 $insert winAPI_WindowMessage_Equates
0002 $insert logical
0003
0004 call send_Message( @window : ".TABLE_1", "QUALIFY_EVENT", |
0005 WM_KEYDOWN$, TRUE$ )
0006
0002 $insert logical
0003
0004 call send_Message( @window : ".TABLE_1", "QUALIFY_EVENT", |
0005 WM_KEYDOWN$, TRUE$ )
0006
Once we've done this we can write a WINMSG event handler for the EditTable that responds to the VK_RETURN keycode:
0001 /*
0002 Example WINMSG event handler to trap the Enter key (VK_RETURN$)
0003 while processing the WM_KEYDOWN$ window message.
0004
0005 hwnd -> handle of the EditTable
0006 message -> Message number - should be WM_KEYDOWN$
0007 wParam -> Virtual Keycode - we are looking for VK_RETURN$
0008 lParam -> Keydown flags - see MSDN for more info!
0009
0010 */
0011
0012 $insert winAPI_WindowMessage_Equates
0013 $insert winAPI_VirtualKey_Equates
0014 $insert logical
0015
0016 begin case
0017 case ( message = WM_KEYDOWN$ )
0018
0019 begin case
0020 case ( wParam = VK_RETURN$ )
0021 // Write your code to handle the event here
0022 call msg( @window, "Enter key pressed!" )
0023
0024 end case
0025
0026 end case
0027
0028 return TRUE$
0002 Example WINMSG event handler to trap the Enter key (VK_RETURN$)
0003 while processing the WM_KEYDOWN$ window message.
0004
0005 hwnd -> handle of the EditTable
0006 message -> Message number - should be WM_KEYDOWN$
0007 wParam -> Virtual Keycode - we are looking for VK_RETURN$
0008 lParam -> Keydown flags - see MSDN for more info!
0009
0010 */
0011
0012 $insert winAPI_WindowMessage_Equates
0013 $insert winAPI_VirtualKey_Equates
0014 $insert logical
0015
0016 begin case
0017 case ( message = WM_KEYDOWN$ )
0018
0019 begin case
0020 case ( wParam = VK_RETURN$ )
0021 // Write your code to handle the event here
0022 call msg( @window, "Enter key pressed!" )
0023
0024 end case
0025
0026 end case
0027
0028 return TRUE$
(Note in these examples we are using some insert records from our WinAPI Library that you can find here)
Captain C
ReplyDeleteWhere Can I find the equates winAPI_WindowMessage_Equates and winAPIVirtualKey_Equates? It is not in my sysprocs.
Thanks
Hello Anonymous,
ReplyDeleteThey can be found the in the WinAPI library (mentioned at the end of the article :) here:
http://sprezzblog.blogspot.com/2010/06/sprezzatura-windows-api-library.html
It's a standard RDK - if you install it you'll find the inserts mentioned above and a whole load of other useful ones too.