• Welcome to PlanetSquires Forums.
 

question(s) about inkey & chr() items...

Started by veltesian, July 24, 2020, 08:00:49 AM

Previous topic - Next topic

veltesian

hello ....

i had tried using these items in a GUI form attempting to make sense of
trying to invoke a key press or something... i wanted to know how to program
a key on the keyboard to act as a button click? for the lack of better words in
using the inkey or chr() items. i tried several different arrangements with those
items & could not get them to work correctly/encounters errors everytime...

i'd gladly thank anyone who could help me with this.



Paul Squires

Inkey() will not work in WinFBE visual designer projects because WinFBE uses the Windows API along with Windows' underlying event driven system. Keypresses generate Windows messages that WinFBE retrieves from the Windows message queue. Those messages are then sent to the applicable control in the form of KeyDown, KeyUp, KeyPress message handlers.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

veltesian

so basically what i was asking about can only be done as a form1 keyup/keydown or keypress ??

José Roca

Inkey only works with console applications, not with GUI applications, no matter if you use WinFBE or whatever. Console applications and GUI applications are very different animals.


Paul Squires

Quote from: veltesian on July 24, 2020, 09:34:00 AM
so basically what i was asking about can only be done as a form1 keyup/keydown or keypress ??

You can also use the keyup/keydown or keypress message handlers for the controls that support them... not just Form1.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

veltesian

#5
i'd like to thank both paul & jose for explaining this to me.... though i'd like to know if i could
perhaps see an example or 2 of the keyup/keydown or keypress message handlers & the CTRLs
that support them. please forgive me as i'm kinda frustrated that i still cannot understand how
to make sense in the utilization of these message handlers. i've coded this *.bas that i tried to
figure out some sort of solution.... it shows/results in no errors but it does nothing.

Petrus Vorster

I have been where you are mate.
These guys will teach you magnificent things.

It is frustrating in the beginning, but you wont find a more helpful forum on the Web.

Add a screenclip of your form you made and what keys you want to trigger certain things.
I must say, i cannot remember when last i used any key press triggers.
Perhaps we can point you in some direction.

I dont know much, but I owe all i know to these people here.
So i will share what i have learned where i can.

-Peter
-Regards
Peter

veltesian

#7
included with this post petrus is the *.bas that i spoke of previously. when i said
i'm frustrated i was referring to my saying i'm more angry at myself. in the *.bas
that i've included with this post is the GUI form that has just 1 label,.... i placed
a form_keypress action/routine? (not entirely sure what it would be called) inside
the form. when i press F5 to compile, then run it displays no errors but it
pretty much does nothing.

ideas on keypress triggering: (i'd like to do these things within a GUI form, not a console)
i hope you'll pardon me if 1 or more of these ideas seem to be ambitious/silly/etc....

1. understanding what code would be necessary to correct the *.bas
i uploaded. that for me would be a good 1st step.

2. understanding what code would be necessary to close a form with a key press
instead of using the red x in the upper right corner.

3. understanding what code would be necessary to start a timer element with a key press
instead of using a command button.

4. understanding what code would be necessary to coerce 1 CTRL to move out of form view
and another CTRL move within view @ the same spot as the previous CTRL.

5. common keys on the keyboard i would like see code for binding to a key press are:
   * z key
   * x key
   * spacebar
   * enter key
   * any number key
   * or the -/+ keys
   * or any of the "F" (function?) keys
   * or the Lshift, LCTRL keys

this list is just a few things that i'd like to learn. by no means is the above list all of what i'd like to know.

Petrus Vorster

I know in VB6 there was this thing called a "KEYPREVIEW".
No matter what you were busy with or on which control you are, if you pressed a key it would trigger an event while that form had focus.

That functionality was not carried forward to Powerbasic, not FF3 and i doubt very much this GUI.
The keyup & keydown will work on a control, but you will have to do that for all controls.
...And not all controls have those functions.

Here it is a bit technical intercepting windows messages, Paul and Josè are the masters there, but their methods allow you to intercept keystrokes, right-clicks and those tricky key-combos one need.
-Regards
Peter

veltesian

sorry about taking so long to complete my previous post
above your last post petrus. i was wracking my brain trying
to figure out what ideas would be good to start in making
sense of the programming code.

Johan Klassen

Hi Petrus
this GUI does support KeyPreview, perhaps you missed this thread https://www.planetsquires.com/protect/forum/index.php?topic=4484.0
@veltesian may I suggest that you have a look at KeyDown instead of KeyPress

Johan Klassen

@veltesian
here you go, I will offline till sunday

Petrus Vorster

Like is said, i have spend little time on this GUi.
But It seems you got your answer.
:-)
-Regards
Peter

veltesian

a big thank you goes out to johan & petrus. its much appreciated. i remember seeing a chart somewhere
that showed codes like the VK_***. though i remembered it did not cover all keys, just a majority of them.
i'll definitely check that link petrus thanks for providing it to me.... (moments pass as i check the link)
and yes i was shown that code. someone helped with that very code as i was needing help recently.

and thanks again to johan.... the fixed *.bas works great. i just wish i could find that page that showed
those VK_*** keycodes. and if some of the keys could not be translated i don't know how i would be
able to employ those certain keys....