I have created a music player that is yet to function to its full ( the add button on my main form1 won't bring up the AddNewWaveTrack_form ).

These errors vary so any help is much appreciated as I want to learn fast.

#pragma once


#include "AddWaveTrack_form1.h"
#include "EditWaveTrack_form1.h"

namespace WaveMachine {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::IO;

	using namespace System::Media;

	/// <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 ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Button^  button3;
	private: System::Windows::Forms::Button^  button4;
	private: System::Windows::Forms::ListView^  listView1;
	private: System::Windows::Forms::ColumnHeader^  columnHeader1;
	private: System::Windows::Forms::ColumnHeader^  columnHeader2;
	


	protected: 

	private:
		/// <summary>
		/// Required designer variable.

		ListViewItem^ trackToEdit;

	private: System::Windows::Forms::Button^  playBtn;
	private: System::Windows::Forms::ColumnHeader^  columnHeader3;

		/// </summary>
		System::ComponentModel::Container ^components;


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->button4 = (gcnew System::Windows::Forms::Button());
			this->playBtn = (gcnew System::Windows::Forms::Button());
			this->listView1 = (gcnew System::Windows::Forms::ListView());
			this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
			this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
			this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(12, 12);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(75, 23);
			this->button1->TabIndex = 0;
			this->button1->Text = L"Add Track";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(12, 41);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(139, 23);
			this->button2->TabIndex = 1;
			this->button2->Text = L"Save Tracks to Database";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
			// 
			// button3
			// 
			this->button3->Location = System::Drawing::Point(12, 96);
			this->button3->Name = L"button3";
			this->button3->Size = System::Drawing::Size(75, 23);
			this->button3->TabIndex = 2;
			this->button3->Text = L"Edit Track";
			this->button3->UseVisualStyleBackColor = true;
			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
			// 
			// button4
			// 
			this->button4->Location = System::Drawing::Point(105, 96);
			this->button4->Name = L"button4";
			this->button4->Size = System::Drawing::Size(75, 23);
			this->button4->TabIndex = 3;
			this->button4->Text = L"Delete Track";
			this->button4->UseVisualStyleBackColor = true;
			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
			// 
			// playBtn
			// 
			this->playBtn->Location = System::Drawing::Point(197, 96);
			this->playBtn->Name = L"playBtn";
			this->playBtn->Size = System::Drawing::Size(75, 23);
			this->playBtn->TabIndex = 4;
			this->playBtn->Text = L"Play Track";
			this->playBtn->UseVisualStyleBackColor = true;
			this->playBtn->Click += gcnew System::EventHandler(this, &Form1::playBtn_Click);
			// 
			// listView1
			// 
			this->listView1->CheckBoxes = true;
			this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^  >(3) {this->columnHeader1, this->columnHeader2, 
				this->columnHeader3});
			this->listView1->GridLines = true;
			this->listView1->Location = System::Drawing::Point(13, 135);
			this->listView1->Name = L"listView1";
			this->listView1->Size = System::Drawing::Size(259, 115);
			this->listView1->TabIndex = 5;
			this->listView1->UseCompatibleStateImageBehavior = false;
			this->listView1->View = System::Windows::Forms::View::Details;
			// 
			// columnHeader1
			// 
			this->columnHeader1->Text = L"Artist";
			// 
			// columnHeader2
			// 
			this->columnHeader2->Text = L"Title";
			// 
			// columnHeader3
			// 
			this->columnHeader3->Text = L"Music File";
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 262);
			this->Controls->Add(this->listView1);
			this->Controls->Add(this->playBtn);
			this->Controls->Add(this->button4);
			this->Controls->Add(this->button3);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"Organize Tracks";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->ResumeLayout(false);

		}
#pragma endregion
	#pragma endregion
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
			 {
				 // Tian: open and parse the file while the form is being loaded
				 // pls. note that you need double '\' for the path
				 // you need to edit the path accordingly when compiling in your PC
				String^ fileToRead = "C:\\Users\\Black Chocobo\\Desktop\\WaveMachine\\TrackListing.txt";
				StreamReader^ objReader = gcnew StreamReader(fileToRead);

				// Tian: split the tracks in the tracks into substring using delimiters ','
				array<Char>^chars = {','};
				IEnumerator^ myEnum;
				String^ line;
				array<String^>^ split;
				ListViewItem^ item;

				while (!objReader->EndOfStream)
				{
					line = objReader->ReadLine();
					split = line->Split( chars );
					myEnum = split->GetEnumerator();
					while ( myEnum->MoveNext() )
					{
						// fill the first column
						String^ text = safe_cast<String^>(myEnum->Current)->Trim();
						if (text == "") break;

						item = gcnew ListViewItem(text);
					
						// fill the second and third column (subItem)
						for (int j=0; j<2; j++) 
						{
							if (myEnum->MoveNext())
							{
								text = safe_cast<String^>(myEnum->Current)->Trim();
								item->SubItems->Add(text);
							}
						}

						// add to the listView
						this->listView1->Items->Add(item);
					}
				}

				// close the file
				objReader->Close();
			}

	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
				 AddWaveTrack_form1 ^ amtf = gcnew AddWaveTrack_form1();

				 // do nothing when the cancel button or 'Esc' is clicked
				 if (amtf->ShowDialog() == ::DialogResult::Cancel) return;
				
				 // retrieve the new track info
				 array<String^>^ info = amtf->getNewTrackInfo();
				 if (info[0] == "") return;
				 
				 // add the new track into the listView
				 ListViewItem^ item = gcnew ListViewItem(info[0]);
				 item->SubItems->Add(info[1]);
				 item->SubItems->Add(info[2]);
				 this->listView1->Items->Add(item);
			 }

	private: System::Void listView1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
			 }

	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 // Tian: full name and path of the file to be updated/overwritten
				String^ fileToUpdate = "C:\\Users\\Black Chocobo\\Desktop\\WaveMachine\\TrackListing.txt";

				// If the file exists and append is false, the file is overwritten.
				 // If the file exists and append is true, the data is appended to the file. Otherwise, a new file is created. 
				StreamWriter^ objWriter = gcnew StreamWriter(fileToUpdate, false);

				for(int i=0; i < this->listView1->Items->Count; i++)
					objWriter->WriteLine(this->listView1->Items[i]->Text + ", "
													+ this->listView1->Items[i]->SubItems[1]->Text + ", "
													+ this->listView1->Items[i]->SubItems[2]->Text);

				// close the writer and write all data into the file
				objWriter->Close();

				// show info to the user
				MessageBox::Show("The track info has been saved into the file.");
 			 }

private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e)
		 {
			 // Tian: for this example, I restrict the selection of one item only. You can make it more flexible
		 	 if(this->listView1->CheckedItems->Count != 1) {
				 MessageBox::Show("Please check one of times from the list below!");
				 return;
			 }

			 trackToEdit = this->listView1->CheckedItems[0];

			 // open the dialog to edit the selected track
			 EditWaveTrack_form1^ emtf = gcnew EditWaveTrack_form1();

			 // pass the information of the item checked to the form for editing purpose
			 emtf->setTrackToEdit(trackToEdit);
			 
			 // do nothing when the cancel button or 'Esc' is clicked
			 if (emtf->ShowDialog() == ::DialogResult::Cancel) return;
				
			 // retrieve the new track info and update the item
			 this->listView1->Update();
		 }

private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e)
		 {
			  // Tian: make sure at least one item is selected by the user
			  if(this->listView1->CheckedItems->Count == 0) {
				 MessageBox::Show("Please check tracks you want to delete!");
				 return;
			 }

			  // remove the checked items
			  for (int i=0; i<this->listView1->CheckedItems->Count; i++)
				  this->listView1->Items->Remove(this->listView1->CheckedItems[i]);
		 }

private: System::Void playBtn_Click(System::Object^  sender, System::EventArgs^  e) {

			
			 // Tian: for this example, I restrict the selection and playing of one track only. You can make it more flexible
		 	 if(this->listView1->CheckedItems->Count != 1) {
				 MessageBox::Show("Please check one of tracks from the list below to play!");
				 return;
			
			 //axWindowsMediaPlayer1->Ctlcontrols->next();
			 int random;
				Random^ rand;
				rand = gcnew Random();
				int count = axWindowsMediaPlayer1->mediaCollection->getAll()->count;
				random = rand->Next(count);
				axWindowsMediaPlayer1->currentMedia = axWindowsMediaPlayer1->mediaCollection->getAll()->Item[random];
				axWindowsMediaPlayer1->Ctlcontrols->play();
		 }
			 }

			 // the actual music file and its path is kept in the second subItem (of each track)
			 String^ filePath = this->listView1->CheckedItems[0]->SubItems[2]->Text;

			 // using soundplayer class to play the sound
			 // note that it can play .wav sound only, and this .wav file must be in PCM (pulse-code modulation) or exception will occur
			 // for this assignment, you may want to choose some of .wav music track to demonstrate 
			SoundPlayer^ player = gcnew SoundPlayer();
			player->SoundLocation = filePath;
			player->Play();

		 }
};
}

Errors :

Error	7	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	340
Error	4	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	339
Error	2	error C3845: 'WaveMachine::Form1::player': only static data members can be initialized inside a ref class or value type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	338
Error	1	error C3845: 'WaveMachine::Form1::filePath': only static data members can be initialized inside a ref class or value type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	333
Error	8	error C2238: unexpected token(s) preceding ';'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	340
Error	5	error C2238: unexpected token(s) preceding ';'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	339
Error	22	error C2227: left of '->play' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	328
Error	17	error C2227: left of '->mediaCollection' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	327
Error	11	error C2227: left of '->mediaCollection' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	325
Error	19	error C2227: left of '->Item' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	327
Error	18	error C2227: left of '->getAll' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	327
Error	12	error C2227: left of '->getAll' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	325
Error	15	error C2227: left of '->currentMedia' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	327
Error	21	error C2227: left of '->Ctlcontrols' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	328
Error	13	error C2227: left of '->count' must point to class/struct/union/generic type	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	325
Error	24	error C2143: syntax error : missing ';' before '}'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	344
Error	9	error C2143: syntax error : missing ';' before '}'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	343
Error	6	error C2143: syntax error : missing ';' before '->'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	340
Error	3	error C2143: syntax error : missing ';' before '->'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	339
Error	20	error C2065: 'axWindowsMediaPlayer1' : undeclared identifier	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	328
Error	14	error C2065: 'axWindowsMediaPlayer1' : undeclared identifier	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	327
Error	16	error C2065: 'axWindowsMediaPlayer1' : undeclared identifier	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	327
Error	10	error C2065: 'axWindowsMediaPlayer1' : undeclared identifier	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	325
Error	26	error C2061: syntax error : identifier 'Form1'	c:\Users\Black Chocobo\Desktop\WaveMachine\managesongs\WaveMachine\WaveMachine\WaveMachine\WaveMachine.cpp	16
Error	23	error C2059: syntax error : '}'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	344
Error	25	error C2059: syntax error : '}'	c:\users\black chocobo\desktop\wavemachine\managesongs\wavemachine\wavemachine\wavemachine\Form1.h	344

Try searching for an open source player written in C++. I've found this to be useful when writing code. Have you read through all the errors yourself? Double check your errors and make a list of the ones you cant fix. A few seem fairly simple to fix.
Happy coding,
TSims11

This article has been dead for over six months. Start a new discussion instead.