Unplanned
Last Updated: 11 Nov 2019 14:13 by ADMIN
Jeff
Created on: 27 Jan 2014 14:31
Category: Window
Type: Feature Request
5
Window: Add system sound support to RadWindow.Alert and RadWindow.Confirm
When creating themed applications using RadControls, the standard Windows MessageBox control looks out of place.  With that in mind, the predefined RadWindows (Alert and Confirm) seem to be natural replacements for a typical MessageBox.  

However, when these dialogs open, they are silent  That is, they don't play any error, warning, or question sounds like the standard MessageBox - which makes them seem "strange" when used as a replacement.

Adding sounds to (for instance) the Alert window is fairly simple and can be accomplished like this:

RadWindow.Alert(new DialogParameters()
{
    Content = new System.Windows.Controls.TextBlock {
        Text = ex.Message, Width = 250, TextWrapping = TextWrapping.Wrap },
    Header = "Update Error",
    Opened = (alertDialog, eventArgs) => System.Media.SystemSounds.Exclamation.Play()
});

Though, it'd be nice if the ability to play a sound was built-in.  I'd suggest that the DialogParameters class used to customize the predefined dialogs be extended to support a SystemSound member of type System.Media.SystemSounds which, if defined, would play the specified sound when the dialog opens.
4 comments
ADMIN
Martin Ivanov
Posted on: 11 Nov 2019 14:13

Hello Joshua,

Thank you for the additional information. This seems very helpful.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Joshua
Posted on: 08 Nov 2019 23:06

This interop call should be used when a menu item is selected by the user with click or Enter:

Win32Api.PlaySound("MenuCommand", default, PlaySoundFlags.SND_ALIAS | PlaySoundFlags.SND_ASYNC);

 

This interop call should be used whenever a menu or submenu appears:

Win32Api.PlaySound("MenuPopup", default, PlaySoundFlags.SND_ALIAS | PlaySoundFlags.SND_ASYNC);

 

Neither of the calls will hang the calling thread. Interop definitions as follows:

 

[Flags]
public enum PlaySoundFlags : uint
{
    SND_SYNC = 0x0000, /* play synchronously (default) */
    SND_ASYNC = 0x0001, /* play asynchronously */
    SND_NODEFAULT = 0x0002, /* silence (!default) if sound not found */
    SND_MEMORY = 0x0004, /* pszSound points to a memory file */
    SND_LOOP = 0x0008, /* loop the sound until next sndPlaySound */
    SND_NOSTOP = 0x0010, /* don't stop any currently playing sound */
    SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */
    SND_ALIAS = 0x00010000, /* name is a registry alias */
    SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */
    SND_FILENAME = 0x00020000, /* name is file name */
    SND_RESOURCE = 0x00040004, /* name is resource name or atom */
    SND_PURGE = 0x0040, /* purge non-static events for task */
    SND_APPLICATION = 0x0080, /* look for application specific association */
    SND_SENTRY = 0x00080000, /* Generate a SoundSentry event with this sound */
    SND_RING = 0x00100000, /* Treat this as a "ring" from a communications app - don't duck me */
    SND_SYSTEM = 0x00200000, /* Treat this as a system sound */
}

public static class Win32Api
{
    [DllImport("winmm.dll", EntryPoint = "PlaySoundW", ExactSpelling = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi, SetLastError = false)]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool PlaySound(
        [In, MarshalAs(UnmanagedType.LPWStr)] string pszSound,
        [In] IntPtr hmod,
        [In] PlaySoundFlags fdwSound);
}


ADMIN
Martin Ivanov
Posted on: 03 May 2019 16:55
Hello Joshua,

Can you please add some more information about the menu's feature request? More specifically, when exactly you expect the menu to play a sound? When you execute a command which set to the Command of RadMenuItem? And when the child menu items open? Or at any other occasion?

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Joshua
Posted on: 27 Apr 2019 19:24
RadMenu also needs system sound effect support. The two sounds are "Menu Command" and "Menu Pop-up".