Catch keystrokes in GRID

Creative ideas/suggestions for HMG

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Catch keystrokes in GRID

Post 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.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Catch keystrokes in GRID

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Catch keystrokes in GRID

Post by mol »

Thanks! I've missed it. I'll try it after weekend.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Catch keystrokes in GRID

Post 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.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Catch keystrokes in GRID

Post by Rathinagiri »

Thanks Claudio. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Catch keystrokes in GRID

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Catch keystrokes in GRID

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Catch keystrokes in GRID

Post by mol »

it would be great to expand GRID and add sth. like OnKeyPressed method - it could be adequate to old tbrowse
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Catch keystrokes in GRID

Post 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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply