PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: FReebasic Keypreview  (Read 925 times)

Petrus Vorster

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 356
FReebasic Keypreview
« on: September 27, 2016, 04:34:43 PM »

It would be very cool if we could get the old VB function of a Keypreview on any form.
I still need keypresses in many tools and the old keypreview made it possible in a single click and a normal function on each form.
No need to catch it in the message pump or figuring out where to catch a key.

This is really a function i would greatly be thankful for.
Logged

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: FReebasic Keypreview
« Reply #1 on: September 27, 2016, 10:19:09 PM »

As you've indicated, the best way to do this is to catch the keypress in the FF_PUMPHOOK checking the incoming Windows message and then check to see if it belongs to the HWND of the control you are interested in.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Petrus Vorster

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 356
Re: FReebasic Keypreview
« Reply #2 on: September 28, 2016, 04:17:53 PM »

Maybe, but that keypreview was incredibly handy.
I assume it would be difficult to make or else someone would have done so already.
Still a feature i would love to have just for just how it simplifies key trapping.
Logged

David Kenny

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 435
  • Windows 7
Re: FReebasic Keypreview
« Reply #3 on: September 29, 2016, 04:51:46 PM »

If you really need it, you can add it yourself.  As Paul said, you can catch it in the all keys FF_PUMPHOOK routine, but then you could forward it on to another routine that would look at what form and control it's from and then pass it on to any other routines that requested a preview of keys bound for a certain form or a certain control, or a class/subset of controls (all editbox's for example).
Logged

Petrus Vorster

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 356
Re: FReebasic Keypreview
« Reply #4 on: September 30, 2016, 11:18:22 AM »

 ;)
I don't have any idea how to do that.
Would like to see how one can do something like that.
I have looked at key trapping in FF, but i find it vague on how to crate something that can be universally applied to all forms or across the project.
The old Vb6 routine made that very easy for novices like myself.
 :-[
Logged

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: FReebasic Keypreview
« Reply #5 on: September 30, 2016, 02:38:10 PM »

> I don't have any idea how to do that.

Easy. Write a class for each kind of control that you want to support. In the class, subclass the Windows control (e.g. for MyEditClass -or wathever- subclass the Edit control, etc.). In the window procedure of the subclassed control catch messages like WM_CHAR (for KeyPress), WM_KEYUP (for KeyUp), WM_KEYDOWN (for KeyDown), WM_LBUTTOUP or WM_LBUTTONDOWN and send a message to the parent window before processing them.

Not very difficult, but a daunting task if you have to write classes for all the controls.

VB 6 used subclassed controls implemented in the runtime or in OCXs.