473,698 Members | 2,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I use PlaySound or play a .WAV file in a Visual C++ Windows Forms Application (.NET) Project?

I'm using Visual Studio .NET 2003.

I get a "Form1.h(24 2): error C2065: 'PlaySound' : undeclared identifier"
error all the time, I've been looking in MSDN for a couple of hours with no
luck, no idea, it's my first program, if you are so kind and could explain
me in detail.

Sorry for my english.

Regards.
Nov 22 '05 #1
2 4708
Can you post the code?
"聲gel Cabrera" <angel.cabrera. batista.847671@ bit_.com> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
I'm using Visual Studio .NET 2003.

I get a "Form1.h(24 2): error C2065: 'PlaySound' : undeclared identifier"
error all the time, I've been looking in MSDN for a couple of hours with no luck, no idea, it's my first program, if you are so kind and could explain
me in detail.

Sorry for my english.

Regards.

Nov 22 '05 #2
Sure.

Form1.h:

-----

#pragma once
namespace sound
{
using namespace System;
using namespace System::Compone ntModel;
using namespace System::Collect ions;
using namespace System::Windows ::Forms;
using namespace System::Data;
using namespace System::Drawing ;

/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to
change the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly
with localized
/// resources associated with this form.
/// </summary>
public __gc class Form1 : public System::Windows ::Forms::Form
{
public:
Form1(void)
{
InitializeCompo nent();
}

protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispos e(disposing);
}
private: System::Windows ::Forms::Button * button1;

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::Compone ntModel::Contai ner * components;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeCompo nent(void)
{
this->button1 = new System::Windows ::Forms::Button ();
this->SuspendLayout( );
//
// button1
//
this->button1->Location = System::Drawing ::Point(8, 8);
this->button1->Name = S"button1";
this->button1->TabIndex = 0;
this->button1->Text = S"button1";
this->button1->Click += new System::EventHa ndler(this,
button1_Click);
//
// Form1
//
this->AutoScaleBaseS ize = System::Drawing ::Size(5, 13);
this->ClientSize = System::Drawing ::Size(292, 273);
this->Controls->Add(this->button1);
this->Name = S"Form1";
this->Text = S"Form1";
this->ResumeLayout(f alse);

}

private: System::Void button1_Click(S ystem::Object * sender,
System::EventAr gs * e)
{
PlaySound("SOUN D.WAV", NULL, SND_SYNC);
}

};
}

-----

Form1.cpp:

-----

#include "stdafx.h"
#include "Form1.h"
#include <windows.h>
#include <mmsystem.h>

using namespace sound;

int APIENTRY _tWinMain(HINST ANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threadi ng::Thread::Cur rentThread->ApartmentSta te =
System::Threadi ng::ApartmentSt ate::STA;
Application::Ru n(new Form1());
return 0;
}

-----

"W.G. Ryan [eMVP]" <WilliamRyanATG mailDotcom> wrote in
news:ub******** ******@TK2MSFTN GP14.phx.gbl:
Can you post the code?
"聲gel Cabrera" <angel.cabrera. batista.847671@ bit_.com> wrote in
message news:u8******** ******@TK2MSFTN GP12.phx.gbl...
I'm using Visual Studio .NET 2003.

I get a "Form1.h(24 2): error C2065: 'PlaySound' : undeclared
identifier" error all the time, I've been looking in MSDN for a
couple of hours with

no
luck, no idea, it's my first program, if you are so kind and could
explain me in detail.

Sorry for my english.

Regards.



Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6435
by: Luis Ferrao | last post by:
Hi, My Windows Forms application uses the WebBrowser control to open an Excel file since OLE objects are gone in .Net. The application is actualy a clone of the one found in the MS Knowledge Base Article "How to Use the WebBrowser Control to Open Office Documents with Visual C# .NET" which can be found here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;304662 The application does what it's supposed to (ie Loads embeded Excel
2
699
by: 聲gel Cabrera | last post by:
I'm using Visual Studio .NET 2003. I get a "Form1.h(242): error C2065: 'PlaySound' : undeclared identifier" error all the time, I've been looking in MSDN for a couple of hours with no luck, no idea, it's my first program, if you are so kind and could explain me in detail. Sorry for my english. Regards.
0
1642
by: David | last post by:
So I'm a new user to Visual Studio .NET. I'm having a problem with an initial setup of a Windows Form Application for a Visual C++ Project. The Windows Form Application (.NET) template is not shown. Any ideas or suggestions of why? I'm pretty sure its not an installation problem because I did a full installation of Visual Studio .Net Professional.
2
9553
by: Steph | last post by:
I am working on a Windows Forms App. I have attached a standard UnhandledExceptionEventHandler to the current domain to catch unexpected errors. In my application, when I trigger an unhandled error, my handler does not get hit - I get the standard ugly run time error. The strange thing is, I tried the exact same code in a new, windows forms application, and when I trigger an unhandled exception, the code works fine (the JIT compiler...
0
1272
by: Richard | last post by:
I have 2 projects that can run independently. One is built using Windows Forms Application (.NET) and the other is built on pure C++. Both project runs fine, but when I try to integrate them, problems arise. I create new Empty Project, and add the 2 existing project. As for C++ project, most of the includes and coding is in .CPP file whereas .H file only contain class definition. As for the form, it is generated and most of the coding...
0
1219
by: Sanjeeva Reddy | last post by:
1)how to get the preview of movie file to add in imagelist(i mean the first frame of movie file. )(in .net frame work,windows Forms application) in a listview control. here i am giving code for adding images in my imagelist below. imageList1->Images->Add(Image::FromFile("C:\\ar1.jpg"); like that only i want to add my movie files(first frame) to my imagelist. 2)imagetransition:in imagetrancistion i want to use transition filter like...
22
6267
by: Jordan S. | last post by:
SQL Server will be used as the back-end database to a non trivial client application. In question is the choice of client application: I need to be able to speak intelligently about when one client (MS Access vs ..NET Windows Forms) would be preferred over the other. While I have some good arguments on both sides, I would appreciate your points of view on the topic.
0
796
by: R.Kaiser | last post by:
In a VS 2005 CLR Windows Forms Application, code has to be written in the header file (form1.h per default), in contrast to usual C++ practice. I heard a rumour that this problem will be fixed in a future version of Visual C++ (Service Pack 1 or the next version of Visual Studio). In addition, I heard that future versions of Visual C++ will allow "partial classes" . Can anybody tell me whether these rumours are true? Does anybody know
1
3211
by: NickP | last post by:
Hi there, Im using System.Windows.Forms.Application.EnableVisualStyles to attempt to apply visual styles to message boxes in a VB.NET 2005 application. Unfortunately this has no effect, the application has the "Application Framework" enabled with "Enable XP Visual Styles" set to true. Any ideas on what I'm missing? Thanks loads in advance!
0
8683
marktang
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8873
tracyyun
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...
0
7740
agi2029
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 projectplanning, coding, testing, and deploymentwithout 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...
1
6528
isladogs
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...
0
4372
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...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.