Page 1 of 1

Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 9:17 am
by mol
Hi!
I want to realise quick search by typing letters or digits while GRID control has focus.
Is there any way to catch pressed keys?
Already, I've defined textbox "SEARCH", where user can enter searched phrase, but there is a prblem when he enter into grid.
He must remember to return to SEARCH textbox.

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 1:51 pm
by Rathinagiri
YES. You can catch and process the pressed keys as you wish using HMG_GetLastCharacter() function as described by Claudio here. This is a treasure and the possibilities will be numerous.

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 2:36 pm
by mol
Thanks! I've missed it. I'll try it after weekend.

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 3:12 pm
by srvet_claudio
Rathinagiri wrote:YES. You can catch and process the pressed keys as you wish using HMG_GetLastCharacter() function as described by Claudio here. This is a treasure and the possibilities will be numerous.
Friend what you say is correct, it is more, I have expanded the function HMG_GetLastCharacter () to capture the keys (and characters) pressed in Menu, DialogBox (eg MsgInfo, etc..), Controls, Windows, etc.

They will be able to detect when the key was pressed or released, it is useful for example when:

IF HMG_GetLastVirtualKeyDown() == VK_F10
MsgInfo() // If you keep down the F10 key produces a cascade of MsgInfo
ENDIF

IF HMG_GetLastVirtualKeyUp() == VK_F10
MsgInfo() // If you keep down the F10 key displays only one MsgInfo
ENDIF

When completed the code I send the new release.

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 4:21 pm
by Rathinagiri
Thanks Claudio. :)

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 4:22 pm
by Rathinagiri
mol wrote:Thanks! I've missed it. I'll try it after weekend.
Please make it working for all grids. It will be an useful utility for all.

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 4:25 pm
by Rathinagiri
srvet_claudio wrote:
Rathinagiri wrote:YES. You can catch and process the pressed keys as you wish using HMG_GetLastCharacter() function as described by Claudio here. This is a treasure and the possibilities will be numerous.
Friend what you say is correct, it is more, I have expanded the function HMG_GetLastCharacter () to capture the keys (and characters) pressed in Menu, DialogBox (eg MsgInfo, etc..), Controls, Windows, etc.

They will be able to detect when the key was pressed or released, it is useful for example when:

IF HMG_GetLastVirtualKeyDown() == VK_F10
MsgInfo() // If you keep down the F10 key produces a cascade of MsgInfo
ENDIF

IF HMG_GetLastVirtualKeyUp() == VK_F10
MsgInfo() // If you keep down the F10 key displays only one MsgInfo
ENDIF

When completed the code I send the new release.
Claudio,

A small request. Instead of getting hWnd and finding out the formname or controlname every time, can't we get the formname/controlname directly? That will be user friendly IMHO.

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 8:13 pm
by mol
it would be great to expand GRID and add sth. like OnKeyPressed method - it could be adequate to old tbrowse

Re: Catch keystrokes in GRID

Posted: Thu Jul 11, 2013 9:55 pm
by srvet_claudio
Rathinagiri wrote:
srvet_claudio wrote:
Rathinagiri wrote:YES. You can catch and process the pressed keys as you wish using HMG_GetLastCharacter() function as described by Claudio here. This is a treasure and the possibilities will be numerous.
Friend what you say is correct, it is more, I have expanded the function HMG_GetLastCharacter () to capture the keys (and characters) pressed in Menu, DialogBox (eg MsgInfo, etc..), Controls, Windows, etc.

They will be able to detect when the key was pressed or released, it is useful for example when:

IF HMG_GetLastVirtualKeyDown() == VK_F10
MsgInfo() // If you keep down the F10 key produces a cascade of MsgInfo
ENDIF

IF HMG_GetLastVirtualKeyUp() == VK_F10
MsgInfo() // If you keep down the F10 key displays only one MsgInfo
ENDIF

When completed the code I send the new release.
Claudio,

A small request. Instead of getting hWnd and finding out the formname or controlname every time, can't we get the formname/controlname directly? That will be user friendly IMHO.
Yes, you just need to create a mask for the new functions that exist, e.g.

Code: Select all

hWnd := 0
nMsg := 0
ch := HMG_GetLastCharacter (@hWnd, [@nMsg], [@wParam], [@lParam] )

example:
IF nMsg == WM_MENUCHAR
    // char is pressed in a menu
ENDIF

nFormIndex    := GetFormIndexByHandle    (hWnd) ---> if hWnd is not a handle to HMG Form return 0
nControlIndex := GetControlIndexByHandle (hWnd) ---> if hWnd is not a handle to HMG Control return 0

IF nFormIndex > 0 || nControlIndex > 0

* GetFormNameByIndex    ( nFormIndex )    ---> Return cName
* GetControlNameByIndex ( nControlIndex ) ---> Return cName

* GetFormTypeByIndex    ( nFormIndex ) --> Return cType
* GetControlTypeByIndex ( nControlIndex ) --> Return cType

* GetFormDataByIndex    (nFormIndex) --> Return aFormData
* GetControlDataByIndex (nControlIndex) --> Return aControlData

* IsFormDeletedByIndex    (nFormIndex) --> Return .T. or .F.
* IsControlDeletedByIndex (nControlIndex) --> Return .T. or .F.

...

ENDIF
If necessary I can create additional functions