Catch keystrokes in GRID

Creative ideas/suggestions for HMG

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3062
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 176 times
Been thanked: 96 times
Contact:

Catch keystrokes in GRID

Post by mol » Thu Jul 11, 2013 9:17 am

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: 5246
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 165 times
Been thanked: 164 times
Contact:

Post by Rathinagiri » Thu Jul 11, 2013 1:51 pm

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: 3062
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 176 times
Been thanked: 96 times
Contact:

Post by mol » Thu Jul 11, 2013 2:36 pm

Thanks! I've missed it. I'll try it after weekend.

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Thu Jul 11, 2013 3:12 pm

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: 5246
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 165 times
Been thanked: 164 times
Contact:

Post by Rathinagiri » Thu Jul 11, 2013 4:21 pm

Thanks Claudio. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Rathinagiri
Posts: 5246
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 165 times
Been thanked: 164 times
Contact:

Post by Rathinagiri » Thu Jul 11, 2013 4:22 pm

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: 5246
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 165 times
Been thanked: 164 times
Contact:

Post by Rathinagiri » Thu Jul 11, 2013 4:25 pm

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: 3062
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 176 times
Been thanked: 96 times
Contact:

Post by mol » Thu Jul 11, 2013 8:13 pm

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: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Thu Jul 11, 2013 9:55 pm

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