472,145 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Play sound for a custom dialog box

I have a windows form configured as a fixed dialog I'm using as a custom
MessageBox (has some additional buttons). How do I get it to play the
standard windows sounds when envoked and can I insert the standard
MessageBox icons into this dialog?

Thanks,

Dennis
Nov 15 '05 #1
5 7054
Dennis, in the Load event for your win form just play your sound of choice
using DirectX 9 or P/Invoke and the Win API. As for the icon, yes you can,
just set the icon for your form to the system icon. The system icons are
found in shell32.dll.

--
Greg Ewing [MVP]
http://www.claritycon.com/
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
I have a windows form configured as a fixed dialog I'm using as a custom
MessageBox (has some additional buttons). How do I get it to play the
standard windows sounds when envoked and can I insert the standard
MessageBox icons into this dialog?

Thanks,

Dennis

Nov 15 '05 #2
HI Dennis,
Another tip, you can find in the registry under
HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\ SystemAsterisk\.Current
which is the file currently being used by the system.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:O7****************@TK2MSFTNGP12.phx.gbl...
I have a windows form configured as a fixed dialog I'm using as a custom
MessageBox (has some additional buttons). How do I get it to play the
standard windows sounds when envoked and can I insert the standard
MessageBox icons into this dialog?

Thanks,

Dennis

Nov 15 '05 #3
Dennis:

This is from my post above, for some reason it didn't show up here before.
Anyway, you can definitely run this without CE.NET...it'll work on the
desktop. Just for reference, running it on ce.net is very similar, but you
need to use core.dll vs. winnm.dll I've used this on many times and a
modified version on PPC so it'll definitely run for you.
[DllIMport("winnm.dll")]
public static extern bool PlaySound(string pszSound, int hmod, fdwSound);

public const int SND_FILENAME = 0x00020000;
public const it SND_ASYNC = 0x0001;
Then to call it
PlaySound("WavFileYouWantToPlay.wav", 0 , SND_FILENAME| SND_ASYNC);

Let me know if you have any troubles.

Bill

Check out the PlaySound API. When the form loads or closes you can just
fire it with whatever sound you want.
BTW, I got this from .NET Framework Solutions, In Search of the Lost Win32
API by John Paul Meuller. He's got some pretty cool stuff in many different
areas, but rolling custom messageboxes is particularly cool. He shows you
how to add help menus to them and a lot of other neat tricks.
Good Luck,

Bill

"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl...
The sndPlaySound is only for Windows CE.Net. So, can I instead use
PlaySound() which is part of the Platform SDK? If so, I do reference the
Winmm.lib?

Dennis

"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
HI Dennis,
Another tip, you can find in the registry under
HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\ SystemAsterisk\.Current which is the file currently being used by the system.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:O7****************@TK2MSFTNGP12.phx.gbl...
I have a windows form configured as a fixed dialog I'm using as a custom MessageBox (has some additional buttons). How do I get it to play the
standard windows sounds when envoked and can I insert the standard
MessageBox icons into this dialog?

Thanks,

Dennis



Nov 15 '05 #4
I now see that sndPlaySound is also supported for Platform SDK. So, the only
question that comes to mind now is how to use the flags in C#?

Thanks,

Dennis
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl...
The sndPlaySound is only for Windows CE.Net. So, can I instead use
PlaySound() which is part of the Platform SDK? If so, I do reference the
Winmm.lib?

Dennis

"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
HI Dennis,
Another tip, you can find in the registry under
HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\ SystemAsterisk\.Current which is the file currently being used by the system.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:O7****************@TK2MSFTNGP12.phx.gbl...
I have a windows form configured as a fixed dialog I'm using as a custom MessageBox (has some additional buttons). How do I get it to play the
standard windows sounds when envoked and can I insert the standard
MessageBox icons into this dialog?

Thanks,

Dennis



Nov 15 '05 #5
Hi Dennis,

You have to search the include files (.h) of the platform SDK and see what
those values are, I just did that and I found it on the file MMSystem.h

this is the declaration:

#define SND_SYNC 0x0000 /* play synchronously (default) */
#define SND_ASYNC 0x0001 /* play asynchronously */
#define SND_NODEFAULT 0x0002 /* silence (!default) if sound not found
*/
#define SND_MEMORY 0x0004 /* pszSound points to a memory file */
#define SND_LOOP 0x0008 /* loop the sound until next
sndPlaySound */
#define SND_NOSTOP 0x0010 /* don't stop any currently playing
sound */

You can define a enum in C# with these values:
public enum SndValues {

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 */

}
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I now see that sndPlaySound is also supported for Platform SDK. So, the only question that comes to mind now is how to use the flags in C#?

Thanks,

Dennis
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl...
The sndPlaySound is only for Windows CE.Net. So, can I instead use
PlaySound() which is part of the Platform SDK? If so, I do reference the
Winmm.lib?

Dennis

"Ignacio Machin" <ignacio.machin AT dot.state.fl.us> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
HI Dennis,
Another tip, you can find in the registry under
HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\ SystemAsterisk\.Current which is the file currently being used by the system.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:O7****************@TK2MSFTNGP12.phx.gbl...
> I have a windows form configured as a fixed dialog I'm using as a custom > MessageBox (has some additional buttons). How do I get it to play the > standard windows sounds when envoked and can I insert the standard
> MessageBox icons into this dialog?
>
> Thanks,
>
> Dennis
>
>



Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by The Road To Utopia | last post: by
1 post views Thread by Ron Provost | last post: by
1 post views Thread by Lam | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.