PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: question(s) about inkey & chr() items...  (Read 211 times)

veltesian

  • Little Newbie
  • *
  • Posts: 31
question(s) about inkey & chr() items...
« on: July 24, 2020, 08:00:49 AM »

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.


Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9301
  • Windows 10
    • PlanetSquires Software
Re: question(s) about inkey & chr() items...
« Reply #1 on: July 24, 2020, 08:43:54 AM »

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

veltesian

  • Little Newbie
  • *
  • Posts: 31
Re: question(s) about inkey & chr() items...
« Reply #2 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 ??
Logged

Josť Roca

  • Guru Member
  • *****
  • Posts: 3274
Re: question(s) about inkey & chr() items...
« Reply #3 on: July 24, 2020, 09:50:28 AM »

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

  • Administrator
  • Guru Member
  • *****
  • Posts: 9301
  • Windows 10
    • PlanetSquires Software
Re: question(s) about inkey & chr() items...
« Reply #4 on: July 24, 2020, 11:05:08 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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

veltesian

  • Little Newbie
  • *
  • Posts: 31
Re: question(s) about inkey & chr() items...
« Reply #5 on: July 24, 2020, 01:06:08 PM »

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.
« Last Edit: July 24, 2020, 01:12:37 PM by veltesian »
Logged

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 465
Re: question(s) about inkey & chr() items...
« Reply #6 on: July 24, 2020, 01:43:20 PM »

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
Logged

veltesian

  • Little Newbie
  • *
  • Posts: 31
Re: question(s) about inkey & chr() items...
« Reply #7 on: July 24, 2020, 01:50:52 PM »

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.
« Last Edit: July 24, 2020, 02:38:21 PM by veltesian »
Logged

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 465
Re: question(s) about inkey & chr() items...
« Reply #8 on: July 24, 2020, 02:08:47 PM »

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.
Logged

veltesian

  • Little Newbie
  • *
  • Posts: 31
Re: question(s) about inkey & chr() items...
« Reply #9 on: July 24, 2020, 02:41:49 PM »

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.
Logged

Johan Klassen

  • Junior Member
  • **
  • Posts: 102
  • FF3 User
Re: question(s) about inkey & chr() items...
« Reply #10 on: July 24, 2020, 02:55:07 PM »

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
Logged

Johan Klassen

  • Junior Member
  • **
  • Posts: 102
  • FF3 User
Re: question(s) about inkey & chr() items...
« Reply #11 on: July 24, 2020, 03:24:15 PM »

@veltesian
here you go, I will offline till sunday
Logged

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 465
Re: question(s) about inkey & chr() items...
« Reply #12 on: July 24, 2020, 03:32:31 PM »

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

veltesian

  • Little Newbie
  • *
  • Posts: 31
Re: question(s) about inkey & chr() items...
« Reply #13 on: July 24, 2020, 10:58:24 PM »

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....
Logged