Thanks Martin.

I will deeply study your answer.


Write you later.


Fre;D

________________________________
De : Martin Schreiber <mse00...@gmail.com>
Envoyé : dimanche 16 juillet 2017 05:17
À : mseide-msegui-talk@lists.sourceforge.net
Objet : Re: [MSEide-MSEgui-talk] TSlider and onmouseevent/onkeydown/onkeyup ?

On Saturday 15 July 2017 18:38:28 Fred van Stappen wrote:
> > In order to trigger value settings before releasing the mouse button
> > activate <tslider>.scrollbar.options sbo_thumbtrack (default true).
>
> Yep, perfect, I get exactly what I want, thanks.
>
> > For the the problem with the thread I would do
>
> Oooops, that is much more complicated than using:
> "onmouseevent" + "onkeyup" + "onkeydown" with "Slider1.tag := 0 (or 1);".
>
You need to call application.lock()/unlock() or use another synchronizing
mechanism while accessing main thread elements from a worker thread or there
will be problems (most likely crashes) sooner or later. How do you protect
gui resources in your code?

"
   if not tslider1.clicked then begin
"
replaces your
"
procedure ASlider.onmousedown(sender: TObject); // idem for onkeydown
begin
ASlider.tag := 1;
end;

procedure ASlider.onmouseup(sender: TObject); // idem for onkeyup
begin
ASlider.tag := 0;
end;

and in the loop of the thread:

...
if ASlider.tag = 0 then ASlider.position := somewhere;
"
why do you think it is "much more complicated"? your code has nine lines, mine
only one and doesn't need event properties. The code I showed is a working
example of a 0..1.0 loop in a thread in order to
demonstrate "tslider1.clicked",

> Also I use in a unit a fpc TThread (not a tthreadcomp), so your code is not
> compatible... And where/when to use that procedure?
>
application.lock()/unlock() and <tslider>.clicked can be used everywhere.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to