Página 2 de 2

Best way to catch keystrokes?

Publicado: Vie Oct 12, 2007 11:33 pm
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

Best way to catch keystrokes?

Publicado: Vie Oct 12, 2007 11:33 pm
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

Best way to catch keystrokes?

Publicado: Vie Oct 12, 2007 11:55 pm
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
------------------------------------------------------------ -

Best way to catch keystrokes?

Publicado: Vie Oct 12, 2007 11:55 pm
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
------------------------------------------------------------ -

Best way to catch keystrokes?

Publicado: Dom Oct 14, 2007 10:47 pm
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

Best way to catch keystrokes?

Publicado: Dom Oct 14, 2007 10:47 pm
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

Best way to catch keystrokes?

Publicado: Lun Oct 15, 2007 10:04 am
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

Best way to catch keystrokes?

Publicado: Lun Oct 15, 2007 10:04 am
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