473,856 Members | 1,642 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 4717
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
6451
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
1655
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
9574
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
1280
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
1230
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
6306
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
804
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
3228
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
9758
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,...
0
11049
Oralloy
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...
1
10772
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10378
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
9527
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
7928
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
7086
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();...
1
4568
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
3
3195
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.