Subject Re: Programmatically Adding An Event
From <rich@autotraker.com> <<rich@autotraker.com>>
Date Thu, 6 Dec 2018 10:00:43 -0500
Newsgroups dbase.getting-started
Attachment(s) SpinEntry.cc

Added the UpdateWindow() API to the  downbutton's loop to cause the button
to repaint.
Makes it a little more eye appealing since you can visibly see the button is
depressed.
Also enables the use of a downBitMap since before the button wasn't getting
repainted during the loop.
I use this type of loop in my VCR style control for navigating a rowset. Now
I need to update my VCR control with some of the changes from this code.
Rich...


wrote in message news:1iSmFaNjUHA.1352@ip-AC1E04A7...

Of course I got bored while having a cup of coffee so I turned it into a CC.
Good excuse not to work on the complicated stuff I'm supposed to be working
on. LOL
Added the onGotFocus events so it'll work in both 2.62/2.80 and plus 12
And changed it so it'll fire the entryfield's onChange event.
Works with both 2.62/2.80 and PLUS 12.
The 2 graphics don't look all that great in 2.62/2.80 but it's working. LOL
Rich...




wrote in message news:0RwV53LjUHA.1832@ip-AC1E04A7...

BTW, this does not work in PLUS 2.80
If you need it to work in PLUS 2.62/2.80 since the onMouseDown doesn't fire
unless the button is enabled, you'll have to enable the buttons in a
onGotFocus event for the entryfields.
And of course the same up and down arrows don't exist in 2.62/2.80
Otherwise it'll work the same for 2.62/2.80 as PLUS 12.
Rich....




wrote in message news:C7pYvtLjUHA.1832@ip-AC1E04A7...

Instead of passing the hWnd of the button, I changed it to pass a object
reference.
That way you can test to see which entryfield has focus via a API. If
neither has focus it'll just return.
And it makes it easier to update the appropriate entryfield.
Added nMultipler in case you wanted a different jump. Changing it to 10 will
give you a jump of 10 each time.
I didn't localize any of my variables or test every combination but this
might get you started down a different road than previous test forms.
Rich...




wrote in message news:wCHQ9cLjUHA.1352@ip-AC1E04A7...

I'm sorry, I posted the wrong form.
I posted one I hadn't finished.
This one is corrected to show the technique to both add and subtract.
Rich...


wrote in message news:$ym54QLjUHA.1832@ip-AC1E04A7...

I took the liberty of taking the demo2b.wfm and altering it along the lines
of the WhileMouseDown functionality.
I stripped most everything out of the form and just left the controls and a
new downbutton function.
I'll leave it up to whoever want to experiment with it to add more
functionality.
When either button is pushed it will add or subtract 1 to the value. If held
down it will repeat adding or subtracting 1 to the value.
The repeat speed is slowed down by using sleep so you can adjust how fast it
repeats.
I pulled the routine out of one of my controls that simulates a spinbox but
I also use it to scroll though a table.
Rich...


"Tom"  wrote in message news:O8yEiBLjUHA.1352@ip-AC1E04A7...

On 12/4/18 5:02 PM, Ronnie MacGregor wrote:
> In article <5GsYlxAjUHA.904@ip-AC1E04A7>, invalid@invalid.invald says...
>
>> Hold
>> the left mouse button down and the entryfield updates continuously.
>   I wonder if you remember my "WhileMouseDown" functionality for
> Jean-Pierre's CD Player (dBulletin)
>
>
Issue 17 for anyone else interested ...

The WhileMouseDown Class

When the left mouse button is pushed and held down over an object, the
latter’s onLeftMouseDown() event is fired only once.  If we want an
action to be repeated while a button is pushed, we could create a loop
in its onLeftMouseDown() event and break that loop when the mouse is
released.  However, that solution is hazardous:  if the mouse is dragged
outside the surface of the button and then released over another object,
we could end up with an infinite loop.

For dBL developers, the real solution is to use a free component
designed by Romain Strieff and Ronnie MacGregor:  their WhileMouseDown
class.  This object does use a loop.  However, in that loop an API call
is made to check if the mouse button is still pushed over the button:
if it is not, the loop is broken from within the onLeftMouseDown() code,
thus preventing the hazardous situation we’ve just spoken about.

Being a visual component, this class can be made available from the
Component palette, and then can be drag’n dropped onto a form under the
Form designer.

Thanks,

Tom