Página 1 de 1

Databrowser keyboard handling

Publicado: Vie Dic 16, 2005 8:36 pm
por Giuseppe Bogetti
Hi,
I would like to modify the navigation behaviour of a TDbfDataBrowser to
allow CTRL-HOME to move to first column and CTRL-END to move to last
column.
This is the code I use and logging all calls to method I found that the
CTRL key is passed but not the HOME neither the END.
METHOD BrowseDataKeyDown( oSender, nKey, nFlags ) CLASS TxNovaTools
SWITCH nKey
CASE VK_HOME // Home
IF ( ( GetAsyncKeyState( VK_CONTROL ) & 1 ) == 1 )
:GoToLeftMost()
RETURN 0
ENDIF
CASE VK_END // End
IF ( ( GetAsyncKeyState( VK_CONTROL ) & 1 ) == 1 )
:GoToRighMost()
RETURN 0
ENDIF
CASE VK_CANCEL // DEL
............
............
END SWITCH
ENDIF
END WITH
RETURN Nil
How can I accomplish this ?
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy

Databrowser keyboard handling

Publicado: Vie Dic 16, 2005 8:48 pm
por jfgimenez
Guiseppe,
> Hi,
> I would like to modify the navigation behaviour of a TDbfDataBrowser to
> allow CTRL-HOME to move to first column and CTRL-END to move to last
> column.
>
> This is the code I use and logging all calls to method I found that the
> CTRL key is passed but not the HOME neither the END.
That's because VK_HOME and VK_END are processed directly by the control, and
the event OnKeyDown is not launched in that case. The only way to do what
you want is deriving the class:
CLASS TBrowse FROM XBrowse
METHOD WMKeyDown( nKey, nFlags )
ENDCLASS
METHOD WMKeyDown( nKey, nFlags ) CLASS TBrowse
IF lAnd( GetKeyState( VK_CONTROL ), 0x80 )
IF nKey == VK_HOME
:GoToLeftMost()
RETURN 0
ELSEIF nKey == VK_END
:GoToRighMost()
RETURN 0
ENDIF
ENDIF
RETURN Super:WMKeyDown( nKey, nFlags )
--
Regards,
Jose F. Gimenez

Databrowser keyboard handling

Publicado: Vie Dic 16, 2005 8:48 pm
por jfgimenez
Guiseppe,
> Hi,
> I would like to modify the navigation behaviour of a TDbfDataBrowser to
> allow CTRL-HOME to move to first column and CTRL-END to move to last
> column.
>
> This is the code I use and logging all calls to method I found that the
> CTRL key is passed but not the HOME neither the END.
That's because VK_HOME and VK_END are processed directly by the control, and
the event OnKeyDown is not launched in that case. The only way to do what
you want is deriving the class:
CLASS TBrowse FROM XBrowse
METHOD WMKeyDown( nKey, nFlags )
ENDCLASS
METHOD WMKeyDown( nKey, nFlags ) CLASS TBrowse
IF lAnd( GetKeyState( VK_CONTROL ), 0x80 )
IF nKey == VK_HOME
:GoToLeftMost()
RETURN 0
ELSEIF nKey == VK_END
:GoToRighMost()
RETURN 0
ENDIF
ENDIF
RETURN Super:WMKeyDown( nKey, nFlags )
--
Regards,
Jose F. Gimenez

Databrowser keyboard handling

Publicado: Vie Dic 16, 2005 10:17 pm
por Giuseppe Bogetti
Il Fri, 16 Dec 2005 20:48:43 +0100, Jose F. Gimenez ha scritto:
Jose,
Thanks
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy

Databrowser keyboard handling

Publicado: Vie Dic 16, 2005 10:17 pm
por Giuseppe Bogetti
Il Fri, 16 Dec 2005 20:48:43 +0100, Jose F. Gimenez ha scritto:
Jose,
Thanks
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy