Board index » cppbuilder » Changing a srollbar position without calling OnChange?

Changing a srollbar position without calling OnChange?


2006-05-06 09:03:50 PM
cppbuilder3
Hi everyone. I have a scollbar which acts as a progress bar for the
playback of a piece of audio. When the users drags this bar the audio
skips forward or backward. My problem is this. Every time the user moves
the scrollbar they call a Skip() function which skips parts of the
audio. If I want to automate the scrollbar movement with the playback so
that it moves automatically with the audio I can't do it without calling
Skip() each time, which I don't want to do. So my question is this, is
there a way to set a scrollbar's position without calling it's OnChange
method? I hope this is clear....
Rory.
 
 

Re:Changing a srollbar position without calling OnChange?

Rory Walsh wrote:
Quote
My problem is this. Every time the user moves
the scrollbar they call a Skip() function which skips parts of the
audio. If I want to automate the scrollbar movement with the playback so
that it moves automatically with the audio I can't do it without calling
Skip() each time, which I don't want to do. So my question is this, is
there a way to set a scrollbar's position without calling it's OnChange
method?
No but you can assign NULL to the ScrollBar OnChange before moving the
scrollbar yourself and restore the OnChange after having moved the
scrollbar. That way, the code in your original OnChange will not be
called. Something like this:
TNotifyEvent OldOnChange = ScrollBar->OnChange;
ScrollBar->OnChange = 0;
// Move your scrollbar
ScrollBar->OnChange = OldOnChange;
Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------
 

Re:Changing a srollbar position without calling OnChange?

Brilliant. I couldn't think of anything to solve this, it was doing my
head in!
Rory.
Michel Leunen wrote:
Quote
Rory Walsh wrote:
>My problem is this. Every time the user moves the scrollbar they call
>a Skip() function which skips parts of the audio. If I want to
>automate the scrollbar movement with the playback so that it moves
>automatically with the audio I can't do it without calling Skip() each
>time, which I don't want to do. So my question is this, is there a way
>to set a scrollbar's position without calling it's OnChange method?

No but you can assign NULL to the ScrollBar OnChange before moving the
scrollbar yourself and restore the OnChange after having moved the
scrollbar. That way, the code in your original OnChange will not be
called. Something like this:

TNotifyEvent OldOnChange = ScrollBar->OnChange;
ScrollBar->OnChange = 0;

// Move your scrollbar

ScrollBar->OnChange = OldOnChange;

Michel
 

{smallsort}