I want to create a sound to alert the user when some event occurs.
How do I do it from my VC++ .NET window form program? 6 2683
>I want to create a sound to alert the user when some event occurs.
>How do I do it from my VC++ .NET window form program?
MessageBeep would probably be the easiest API to use. If you need a
more complex facility, have a look at the PlaySound API. For the .Net
world, it looks like similar facilities are available from the
System.Media namespace - SystemSound::Pl ay for instance.
Dave
Dear Dave:
I use the following code to call MessageBeep from my VC++ .net window form
program
[DllImport("user 32.dll", SetLastError=tr ue)]
static bool MessageBeep(UIN T type);
MessageBeep(-1);
However I do not hear a beep sound.
Also I do not see the System::Media namespace in my Visual Studio 2003 .NET.
Kueishiong Tu
"David Lowndes" wrote:
I want to create a sound to alert the user when some event occurs.
How do I do it from my VC++ .NET window form program?
MessageBeep would probably be the easiest API to use. If you need a
more complex facility, have a look at the PlaySound API. For the .Net
world, it looks like similar facilities are available from the
System.Media namespace - SystemSound::Pl ay for instance.
Dave
>I use the following code to call MessageBeep from my VC++ .net window form
>program
[DllImport("user 32.dll", SetLastError=tr ue)] static bool MessageBeep(UIN T type);
You don't need to go to that rigmarole - this is C++ not C# :)
Just #include<window s.hand add the call to the API.
>MessageBeep(-1);
Try MessageBeep(MB_ OK) - it should produce whatever system sound you
have set up in the Control Panel Sound setting.
>Also I do not see the System::Media namespace in my Visual Studio 2003 .NET.
I don't have VS2003 installed, but the following works for me with
VS2008:
#include "stdafx.h"
#include<window s.h>
#pragma comment( lib, "User32.lib " )
using namespace System;
int main(array<Syst em::String ^^args)
{
Console::WriteL ine(L"Hello World");
MessageBeep( -1 );
System::Media:: SystemSounds::B eep->Play();
return 0;
}
Dave
Dear Dave:
"David Lowndes" wrote:
I use the following code to call MessageBeep from my VC++ .net window form
program
[DllImport("user 32.dll", SetLastError=tr ue)]
static bool MessageBeep(UIN T type);
You don't need to go to that rigmarole - this is C++ not C# :)
Just #include<window s.hand add the call to the API.
If I don't do the DllImport, the IDE will complain unresolved token
"MessageBee p" when I try to build the solution in VS2003 VC++ .NET.
I don't have VS2003 installed, but the following works for me with
VS2008:
#include "stdafx.h"
#include<window s.h>
#pragma comment( lib, "User32.lib " )
using namespace System;
int main(array<Syst em::String ^^args)
{
Console::WriteL ine(L"Hello World");
MessageBeep( -1 );
System::Media:: SystemSounds::B eep->Play();
return 0;
}
I try the same code on my VS2008 VC++ express, but I still get no sound even
I turn the speaker to the loudest level and my window media player does play
sound.
Kueishiong Tu
>I don't have VS2003 installed, but the following works for me with
>VS2008:
#include "stdafx.h" #include<windo ws.h>
#pragma comment( lib, "User32.lib " )
using namespace System;
int main(array<Syst em::String ^^args) { Console::WriteL ine(L"Hello World"); MessageBeep( -1 );
System::Media:: SystemSounds::B eep->Play(); return 0; } I try the same code on my VS2008 VC++ express, but I still get no sound even I turn the speaker to the loudest level and my window media player does play sound.
If you use the Control Panel, Sound applet and play the default beep
from there, does that work?
Dave
If you use the Control Panel, Sound applet and play the default beep
from there, does that work?
Dave
It does not initially. I fix it. Now it works fine. Thank you very much for
your help.
Kueishiong Tu This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Xanax |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
I am interested in developing my own decoding software for CW , PSK , FSK
etc used on the Ham radio bands.
Is it possible to use MS Visual C++ studio to develope something that uses
the Creative Sound CArd as the sampling device???
|
by: Michael Lauzon |
last post by:
This is not for a class, I have a group on SourceForge, this is what
one of the Developers is asking; the more advanced you can make it
right off all the better!:
Can someone please create some MySQL to create the first table: the
players table.
It will need to include (as a minimum):
- ID (unique)
|
by: brazilnut52 |
last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better
I have created a simple COM DLL in .NET by using the COM class template and by setting output to a type library (DLL). All the object does is return a string value. At this point I have not checked the option to register for COM interop in Visual Studio
So I go into Excel (where I want to use the object). Go to VB...
|
by: Viviana Vc |
last post by:
How can I programatically do the equivalent of the following:
cacls "C:\Program Files\test" /T /G Everyone:f ?
Thanks,
Viv
|
by: Ralph |
last post by:
Hi all,
Recently I have tried to create a static lib using MS VC++.
The following are some of the excerpt of my codes:
********* MyFirstStaticLib.c *******************
#include <stdlib.h>
#include <string.h>
| |
by: Tatu Portin |
last post by:
Have this kind of struct:
typedef struct {
char **user_comments;
/* ... */
} vorbis_comment;
/* prototype */
char * read_vorbis_string
( FILE *sc);
|
by: Peteroid |
last post by:
Can anybody point me to or give a simple source example of a managed C++
application that can play a wav sound file? I know a little about
playSound(), but it doesn't seem to like to compile (even though it's
'recognized' via type-ahead in the editor). Required header files might be
my problem, not sure...
Thanx in advance! :)
|
by: richardbustarde |
last post by:
Using VC++ .NET, How can you
1. Play sound or
2. start BEEP sound
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |