I have a slider and a webbrowser object in my form and moving, it should change the volume, however it moves the slider as shown here: 
but it does not change the actual output of the volume. This is probably due to the fact that I integrated the WebBrowser object and used Windows 7. When I manually move the slider (the one shown in the screenshot), the volume output changes. When playing a WAV file, the volume output changesbut not with a WebBrowser object.
I am using the following code:
Xaml
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Slider Minimum="0" Maximum="10" ValueChanged="ValueChanged"/>
</Grid>
</Window>
WITH#
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
private void ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
double newVolume = ushort.MaxValue * e.NewValue / 10.0;
uint v = ((uint) newVolume) & 0xffff;
uint vAll = v | (v << 16);
int retVal = NativeMethods.WaveOutSetVolume(IntPtr.Zero, vAll);
Debug.WriteLine(retVal);
}
}
static class NativeMethods
{
[DllImport("winmm.dll", EntryPoint = "waveOutSetVolume")]
public static extern int WaveOutSetVolume(IntPtr hwo, uint dwVolume);
}
source
share