In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Best way to catch keystrokes?

Xailer professional forum in English
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Best way to catch keystrokes?

Mensaje por Mahanimann »

> I forgot to say that it is possible to make the code a little cleaner:
>
> IF LGetKeyState( VK_CONTROL )
> // Handle CTRL + key strokes
> DO CASE
> CASE nKey == VK_F2
> ...
> CASE nKey == VK_F3
> ELSEIF LGetKeyState( VK_SHIFT )
> // Handle SHIFT + key strokes
> DO CASE
> CASE nKey == VK_F2
> ...
> CASE nKey == VK_F3
> ENDIF
Thanks, I saw this in an answer you wrote in local.<something>.spanish, it's
a clean and easy way.
>> To avoid questions about this, at least from old Clipper-heads, I suggest
>> you put something about this in the Xailer help file. .....
> This is used on many of the samples included in Xailer. Anyhow I'm
> thinking on adding some grep alike tool so anybody can search in all
> xailer's code base to solve doubts.
Non-spesific samples scattered around here and there is in my oppinion not
"analogous" with the standards of Xailer :-) I have deep-searched the
newsgroups and translated (through Babelfish) many spanish answers you and
Ignacio have written and copied them to a small document for reference.
It's not much and just fragments, but it's enough to get me started without
bothering you. The time you spend on documenting this I'm sure you'll save
in the long run.
A grep-tool would be a great tool for everyone, and I'm sure also save you
guys a lot of newsgroup-time in the future.
Again, thanks.
Paal
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Best way to catch keystrokes?

Mensaje por Mahanimann »

> I forgot to say that it is possible to make the code a little cleaner:
>
> IF LGetKeyState( VK_CONTROL )
> // Handle CTRL + key strokes
> DO CASE
> CASE nKey == VK_F2
> ...
> CASE nKey == VK_F3
> ELSEIF LGetKeyState( VK_SHIFT )
> // Handle SHIFT + key strokes
> DO CASE
> CASE nKey == VK_F2
> ...
> CASE nKey == VK_F3
> ENDIF
Thanks, I saw this in an answer you wrote in local.<something>.spanish, it's
a clean and easy way.
>> To avoid questions about this, at least from old Clipper-heads, I suggest
>> you put something about this in the Xailer help file. .....
> This is used on many of the samples included in Xailer. Anyhow I'm
> thinking on adding some grep alike tool so anybody can search in all
> xailer's code base to solve doubts.
Non-spesific samples scattered around here and there is in my oppinion not
"analogous" with the standards of Xailer :-) I have deep-searched the
newsgroups and translated (through Babelfish) many spanish answers you and
Ignacio have written and copied them to a small document for reference.
It's not much and just fragments, but it's enough to get me started without
bothering you. The time you spend on documenting this I'm sure you'll save
in the long run.
A grep-tool would be a great tool for everyone, and I'm sure also save you
guys a lot of newsgroup-time in the future.
Again, thanks.
Paal
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Best way to catch keystrokes?

Mensaje por Mahanimann »

> Hopefully the last question about this: HB_KeyPut() and KEYBOARD does not
> work either. What is the Xailer equivalent for f.ex. this:
>
> HB_KeyPut( K_SH_TAB )
> KEYBOARD "Xailer rocks!"
> KEYBOARD "Xailer rocks!" + K_CTRL_F2
I think I have found an answer for this (it is no real equivalent for
KEYBOARD), but I had to translate some from spanish (through Babelfish):
---START-------------------------------------------------
To send a nKey to a control:
You must use Postmessage(), in the precise object that controls nKey by
ejecting in the :OnKeyDown() Event of the Edit:
::oEdit1:PostMsg(VM_KEYDOWN, VK_INSERT)
Or: oEdit:SendMsg( WM_CHAR, nKey )
To change f.ex the default F4-show dropdown list in f.ex TDateEdit to
something else, f.ex. F1:
CLASS TDateEdit FROM XDateEdit
METHOD WMKeyDown()
ENDCLASS
METHOD WMKeyDown( nKey, nFlags ) CLASS TDateEdit
IF nKey == VK_F1
nKey := VK_F4
ENDIF
RETURN Super:WMKeyDown( nKey, nFlags )
---END-------------------------------------------------
I also found this which you replied to someone concerning the same issue:
---START-------------------------------------------------
In general, every windows message (WM_xxxx) are routed to its corresponding
method WMxxxx in the class (note that the underscore (_) is not present in
the method name). The parameters nWParam and nLParam are always passed. If
there is no such method in the class, then the method HandleEvent( nMsg,
nWParam, nLParam ) is called, if it's present.
In either case, if there is no destination method or that method returns
Nil, then Xailer calls DefWindowProc() or CallWindowProc() with the original
WndProc handle.
This is the way Xailer runs. Of course, those windows messages are explained
in the API documentation (MS Platform SDK Help), and you need to read it if
you want to override any processing of them.
Most messages processing consist on doing something and / or calling its
corresponding event. I.e. WM_KEYDOWN launches the method WMKeyDown(), which
process any meaninfull key for that control or calls OnKeyDown() otherwise.
---END-------------------------------------------------
The knowledge of this saves your users hours and hours of trial and error.
This is for me vital information to know, and I think it's mandatory in the
help-file. Both you and Ignacio are very good to express yourself in
writing, and the fact that you also are very good in what you are to
explain... well, it's a win-win situation.
Just my oppinion :-)
Below is other stuff from the newsgroups I have found to be usefull, I just
put it in here in case a newbie is interested.
Thanks,
Paal
------------------------------------------------------------
> 3. Is "Keyboard" command still working in xHarbour ? if so, can I issue a
> Keyboard VK_F12
Keyboard command does not work in GUI applications. BTW you may simulate the
keystroke this way:
oEditControl:PostMsg( WM_KEYDOWN, VK_F12 )
> When will this event :PostMsg be fired ?
> Moreover, when will :SendMsg event be fired ?
:PostMsg() put the message on top of the messages queue, and is processed
after all other previous messages. :SendMsg() bypass the messages queue, and
send the message to be processed inmediately. :SendMsg() doesn't return
until the message is processed, while :PostMsg() returns inmediately.
> Any way to fire a PostMsg event without attaching it to a control?
No. Every message has to be sent to a control. In fact, one of the message's
members is the control's handle, and cannot be 0 nor an unexistent control.
However, you may post a message directly to the form. I.e.: you can post the
special message WM_XAILER to the own form (::PostMsg( WM_XAILER,...)) and
the form will receive it throw a method called WMXailer():
...
::PostMsg( WM_XAILER, 1, 2 )
...
METHOD WMXailer( nWParam, nLParam )
LogDebug( nWParam, nLParam ) // Result is 1 2
RETURN Nil
------------------------------------------------------------ -
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Best way to catch keystrokes?

Mensaje por Mahanimann »

> Hopefully the last question about this: HB_KeyPut() and KEYBOARD does not
> work either. What is the Xailer equivalent for f.ex. this:
>
> HB_KeyPut( K_SH_TAB )
> KEYBOARD "Xailer rocks!"
> KEYBOARD "Xailer rocks!" + K_CTRL_F2
I think I have found an answer for this (it is no real equivalent for
KEYBOARD), but I had to translate some from spanish (through Babelfish):
---START-------------------------------------------------
To send a nKey to a control:
You must use Postmessage(), in the precise object that controls nKey by
ejecting in the :OnKeyDown() Event of the Edit:
::oEdit1:PostMsg(VM_KEYDOWN, VK_INSERT)
Or: oEdit:SendMsg( WM_CHAR, nKey )
To change f.ex the default F4-show dropdown list in f.ex TDateEdit to
something else, f.ex. F1:
CLASS TDateEdit FROM XDateEdit
METHOD WMKeyDown()
ENDCLASS
METHOD WMKeyDown( nKey, nFlags ) CLASS TDateEdit
IF nKey == VK_F1
nKey := VK_F4
ENDIF
RETURN Super:WMKeyDown( nKey, nFlags )
---END-------------------------------------------------
I also found this which you replied to someone concerning the same issue:
---START-------------------------------------------------
In general, every windows message (WM_xxxx) are routed to its corresponding
method WMxxxx in the class (note that the underscore (_) is not present in
the method name). The parameters nWParam and nLParam are always passed. If
there is no such method in the class, then the method HandleEvent( nMsg,
nWParam, nLParam ) is called, if it's present.
In either case, if there is no destination method or that method returns
Nil, then Xailer calls DefWindowProc() or CallWindowProc() with the original
WndProc handle.
This is the way Xailer runs. Of course, those windows messages are explained
in the API documentation (MS Platform SDK Help), and you need to read it if
you want to override any processing of them.
Most messages processing consist on doing something and / or calling its
corresponding event. I.e. WM_KEYDOWN launches the method WMKeyDown(), which
process any meaninfull key for that control or calls OnKeyDown() otherwise.
---END-------------------------------------------------
The knowledge of this saves your users hours and hours of trial and error.
This is for me vital information to know, and I think it's mandatory in the
help-file. Both you and Ignacio are very good to express yourself in
writing, and the fact that you also are very good in what you are to
explain... well, it's a win-win situation.
Just my oppinion :-)
Below is other stuff from the newsgroups I have found to be usefull, I just
put it in here in case a newbie is interested.
Thanks,
Paal
------------------------------------------------------------
> 3. Is "Keyboard" command still working in xHarbour ? if so, can I issue a
> Keyboard VK_F12
Keyboard command does not work in GUI applications. BTW you may simulate the
keystroke this way:
oEditControl:PostMsg( WM_KEYDOWN, VK_F12 )
> When will this event :PostMsg be fired ?
> Moreover, when will :SendMsg event be fired ?
:PostMsg() put the message on top of the messages queue, and is processed
after all other previous messages. :SendMsg() bypass the messages queue, and
send the message to be processed inmediately. :SendMsg() doesn't return
until the message is processed, while :PostMsg() returns inmediately.
> Any way to fire a PostMsg event without attaching it to a control?
No. Every message has to be sent to a control. In fact, one of the message's
members is the control's handle, and cannot be 0 nor an unexistent control.
However, you may post a message directly to the form. I.e.: you can post the
special message WM_XAILER to the own form (::PostMsg( WM_XAILER,...)) and
the form will receive it throw a method called WMXailer():
...
::PostMsg( WM_XAILER, 1, 2 )
...
METHOD WMXailer( nWParam, nLParam )
LogDebug( nWParam, nLParam ) // Result is 1 2
RETURN Nil
------------------------------------------------------------ -
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Best way to catch keystrokes?

Mensaje por notengo »

Mahanimann,
> Non-spesific samples scattered around here and there is in my oppinion not
> "analogous" with the standards of Xailer :-) I have deep-searched the
> newsgroups and translated (through Babelfish) many spanish answers you and
> Ignacio have written and copied them to a small document for reference.
> It's not much and just fragments, but it's enough to get me started without
> bothering you. The time you spend on documenting this I'm sure you'll save
> in the long run.
Just a note, that answer was not mine, it was from my boss Jose F., we are
two different "Jose".
> A grep-tool would be a great tool for everyone, and I'm sure also save you
> guys a lot of newsgroup-time in the future.
I will publish it ASAP.
Regards,
José Lalí­n
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Best way to catch keystrokes?

Mensaje por notengo »

Mahanimann,
> Non-spesific samples scattered around here and there is in my oppinion not
> "analogous" with the standards of Xailer :-) I have deep-searched the
> newsgroups and translated (through Babelfish) many spanish answers you and
> Ignacio have written and copied them to a small document for reference.
> It's not much and just fragments, but it's enough to get me started without
> bothering you. The time you spend on documenting this I'm sure you'll save
> in the long run.
Just a note, that answer was not mine, it was from my boss Jose F., we are
two different "Jose".
> A grep-tool would be a great tool for everyone, and I'm sure also save you
> guys a lot of newsgroup-time in the future.
I will publish it ASAP.
Regards,
José Lalí­n
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Best way to catch keystrokes?

Mensaje por jfgimenez »

José,
> Just a note, that answer was not mine, it was from my boss Jose F., we are
> two different "Jose".
None of us are boss of nobody else from our team. We are just friends ;-)
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Best way to catch keystrokes?

Mensaje por jfgimenez »

José,
> Just a note, that answer was not mine, it was from my boss Jose F., we are
> two different "Jose".
None of us are boss of nobody else from our team. We are just friends ;-)
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Responder