PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Petrus Vorster on September 27, 2016, 05:04:43 PM

Title: FReebasic Keypreview
Post by: Petrus Vorster on September 27, 2016, 05:04: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.
Title: Re: FReebasic Keypreview
Post by: Paul Squires on September 27, 2016, 10:49: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.
Title: Re: FReebasic Keypreview
Post by: Petrus Vorster on September 28, 2016, 04:47: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.
Title: Re: FReebasic Keypreview
Post by: David Kenny on September 29, 2016, 05:21: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).
Title: Re: FReebasic Keypreview
Post by: Petrus Vorster on September 30, 2016, 11:48: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.
:-[
Title: Re: FReebasic Keypreview
Post by: José Roca on September 30, 2016, 03:08: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.