increase granularity of slider control

M

mp

from Windows Sdk sample:
...\Microsoft
SDKs\Windows\v7.0\Samples\multimedia\WMP\dotNet\csharp\WMPCSharp.csproj

in a windows media player sample a slider (trackbar) is used to change
current position
it jumps farther at a time than i want when moved with mouse

anyone know how to adjust the increments of movement with mouse or arrow
keys?
the comments say sensitivity is hardcoded at 100
/// The trackbar has a fixed resolution of 100 ticks.

I don't know if that means in the code or the control itself is limited to
that?
here is a snip out of the sample
private void InitializeComponent()

{

.....
this.tbSeek = new System.Windows.Forms.TrackBar();

////// from the help: The key properties of the TrackBar control are Value,
TickFrequency, Minimum, and Maximum.

/// i tried messing with the following but they seem to not provide the
desired result

this.tbSeek.SmallChange = 1;

this.tbSeek.LargeChange = 10;

this.tbSeek.TickFrequency = 1;



//in the scroll event...

private void tbSeek_Scroll(object sender, System.EventArgs e)

{

try

{

if(Player.currentMedia.duration != 0)

{//how to make the slider more sensitivce so you can change one second at a
time ????

double newPerc = Convert.ToDouble(tbSeek.Value) / 100; // <--------- should
this change the increment??? i tried 10 and 1000 but they don't seem to do
the trick???

int duration = Convert.ToInt32(Player.currentMedia.duration * 1000); //
milliseconds

double newPos = (duration * newPerc)/1000; // seconds

// Seek the Player

Player.Ctlcontrols.currentPosition = newPos;

}



thanks for any tips

mark
 
M

Mike 'Spike' Lovell

mp said:
from Windows Sdk sample:
...\Microsoft
SDKs\Windows\v7.0\Samples\multimedia\WMP\dotNet\csharp\WMPCSharp.csproj

in a windows media player sample a slider (trackbar) is used to change
current position
it jumps farther at a time than i want when moved with mouse

anyone know how to adjust the increments of movement with mouse or arrow
keys?
the comments say sensitivity is hardcoded at 100
/// The trackbar has a fixed resolution of 100 ticks.

I don't know if that means in the code or the control itself is limited to
that?
here is a snip out of the sample
private void InitializeComponent()

{

....
this.tbSeek = new System.Windows.Forms.TrackBar();

////// from the help: The key properties of the TrackBar control are
Value, TickFrequency, Minimum, and Maximum.

/// i tried messing with the following but they seem to not provide the
desired result

this.tbSeek.SmallChange = 1;

this.tbSeek.LargeChange = 10;

this.tbSeek.TickFrequency = 1;



//in the scroll event...

private void tbSeek_Scroll(object sender, System.EventArgs e)

{

try

{

if(Player.currentMedia.duration != 0)

{//how to make the slider more sensitivce so you can change one second at
a time ????

double newPerc = Convert.ToDouble(tbSeek.Value) / 100; // <---------
should this change the increment??? i tried 10 and 1000 but they don't
seem to do the trick???

int duration = Convert.ToInt32(Player.currentMedia.duration * 1000); //
milliseconds

double newPos = (duration * newPerc)/1000; // seconds

// Seek the Player

Player.Ctlcontrols.currentPosition = newPos;

}



thanks for any tips

mark

You set 'SmallChange' to 1 yet you cannot control the the granularity to
that extend with the mouse?

What are the Min and Max settings for it?

~ Mike
 
M

mp

Mike 'Spike' Lovell said:
You set 'SmallChange' to 1 yet you cannot control the the granularity to
that extend with the mouse?

What are the Min and Max settings for it?

~ Mike

i didn't try min or max...assumed they were somehow internally set by size
of file selected?
I thought the smallChange would do it per the help files but it seems to
jump around somewhat unpredictably when i try to move small increments with
mouse
I stretched the original form to make the slider longer thinking more pixels
would allow finer adjustment but no joy
would min and max just be relative to size of file? so the larger i set max
the more fine the adjustment could be???

i was thinking the secret would be in the _Scroll event
private void tbSeek_Scroll(object sender, System.EventArgs e)

{ ....

//double newPerc = Convert.ToDouble(tbSeek.Value) / 10;

//double newPerc = Convert.ToDouble(tbSeek.Value) / 100;

//double newPerc = Convert.ToDouble(tbSeek.Value) / 1000; <--- this looks
like it wants to work but the pointer jumps around after releasing mouse

int duration = Convert.ToInt32(Player.currentMedia.duration * 1000); //
milliseconds

double newPos = (duration * newPerc)/1000; // seconds

// Seek the Player

Player.Ctlcontrols.currentPosition = newPos;

.....

thanks for responding
mark
 
M

Mike 'Spike' Lovell

mp said:
i didn't try min or max...assumed they were somehow internally set by size
of file selected?
I thought the smallChange would do it per the help files but it seems to
jump around somewhat unpredictably when i try to move small increments
with mouse
I stretched the original form to make the slider longer thinking more
pixels would allow finer adjustment but no joy
would min and max just be relative to size of file? so the larger i set
max the more fine the adjustment could be???

i was thinking the secret would be in the _Scroll event
private void tbSeek_Scroll(object sender, System.EventArgs e)

{ ....

//double newPerc = Convert.ToDouble(tbSeek.Value) / 10;

//double newPerc = Convert.ToDouble(tbSeek.Value) / 100;

//double newPerc = Convert.ToDouble(tbSeek.Value) / 1000; <--- this looks
like it wants to work but the pointer jumps around after releasing mouse

int duration = Convert.ToInt32(Player.currentMedia.duration * 1000); //
milliseconds

double newPos = (duration * newPerc)/1000; // seconds

// Seek the Player

Player.Ctlcontrols.currentPosition = newPos;

Hmm not sure, never used the exact control.

But I do know from using the base of that control that it's not been erratic
for me.

Can you not make your own class which inherits that one, and the override
the min/max settings (perhaps its it's max size is the filesize in bytes,
use kb and lose some of the accuracy but gain better mouse control)

~ Mike
 
M

mp

Mike 'Spike' Lovell said:
i didn't try min or max...assumed they were somehow internally set by
size of file selected?
[...]

Hmm not sure, never used the exact control.

But I do know from using the base of that control that it's not been
erratic for me.

Can you not make your own class which inherits that one, and the override
the min/max settings (perhaps its it's max size is the filesize in bytes,
use kb and lose some of the accuracy but gain better mouse control)

~ Mike
Thanks again Mike,
I'd like to learn how to make a class inherit the built in control (i'm just
beginning to try to learn c# so much i don't know)
will search out tutorials on that...if you have any sites you know of that
would have simple examples that would be great too!
Thanks
mark
 
W

wannabe geek

It's pretty easy.

class InheritedControlType : OriginalControlType
{
// add extra implementation in the class block

// most things are overriden using 'override' or 'new'
}

You may have seen this when working with forms and their code

--

Wannabe Geek


mp said:
Mike 'Spike' Lovell said:
from Windows Sdk sample:
...\Microsoft
SDKs\Windows\v7.0\Samples\multimedia\WMP\dotNet\csharp\WMPCSharp.csproj

...

thanks for any tips

mark



You set 'SmallChange' to 1 yet you cannot control the the granularity to
that extend with the mouse?

What are the Min and Max settings for it?

~ Mike

i didn't try min or max...assumed they were somehow internally set by
size of file selected?
[...]

Hmm not sure, never used the exact control.

But I do know from using the base of that control that it's not been
erratic for me.

Can you not make your own class which inherits that one, and the override
the min/max settings (perhaps its it's max size is the filesize in bytes,
use kb and lose some of the accuracy but gain better mouse control)

~ Mike
Thanks again Mike,
I'd like to learn how to make a class inherit the built in control (i'm just
beginning to try to learn c# so much i don't know)
will search out tutorials on that...if you have any sites you know of that
would have simple examples that would be great too!
Thanks
mark


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top