In C++ I have a char[256] variable that is populated by a call to an external DLL which fills it with data. From there I would like to add the char[] as a ComboBox item.
char name[256];
name[0] = "76";
comboBox1->Items->Add(name);
This creates a build error because char[] is not a type of System::Object. Any ideas on converting the char[] to something I can add as an Item to a ComboBox control? Converting to a string would be just fine but I'm not sure quite how to do that. Plus if I try to create a variable such as:
string strName;
also creates an error for missing ';' before identifier 'strName'. I'm a beginner to C++ and am still getting my brain wrapped around it so thanks for any help provided!
EDIT Full code as requested:
#pragma once
namespace FMODMultipleSoundcardWindowed {
#include <string>
#include "inc/fmod.h"
#include "inc/fmod_errors.h"
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 std;
FMOD_SYSTEM *systemA, *systemB;
FMOD_SOUND *soundA, *soundB;
FMOD_CHANNEL *channelA = 0, *channelB = 0;
FMOD_DSP *dspNormalizerA, *dspNormalizerB;
FMOD_DSP *dspCompressorA, *dspCompressorB;
FMOD_DSP *dspEqualizerA[10], *dspEqualizerB[10];
FMOD_DSP *dspVSTVUA, *dspVSTVUB;
FMOD_RESULT result;
unsigned int dspVSTVUHandleA, dspVSTVUHandleB;
unsigned int version;
int numdrivers, count;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
result = FMOD_System_Create(&systemA);
ERRCHECK(result);
result = FMOD_System_GetVersion(systemA, &version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
MessageBox::Show("You are using an old version of FMOD!");
}
result = FMOD_System_GetNumDrivers(systemA, &numdrivers);
ERRCHECK(result);
for (count = 0; count < numdrivers; count++)
{
char name[256];
result = FMOD_System_GetDriverInfo(systemA, count, name, 256, 0);
ERRCHECK(result);
m_objPrimaryAudioDeviceComboBox->Items->Add(name[0]);
}
}
void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
MessageBox::Show("FMOD Error!");
this->Close();
}
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::ComboBox^ m_objPrimaryAudioDeviceComboBox;
protected:
private: System::Windows::Forms::ComboBox^ m_objSecondaryAudioDeviceComboBox;
private:
System::ComponentModel::Container ^components;
pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->m_objPrimaryAudioDeviceComboBox = (gcnew System::Windows::Forms::ComboBox());
this->m_objSecondaryAudioDeviceComboBox = (gcnew System::Windows::Forms::ComboBox());
this->SuspendLayout();
//
// m_objPrimaryAudioDeviceComboBox
//
this->m_objPrimaryAudioDeviceComboBox->FormattingEnabled = true;
this->m_objPrimaryAudioDeviceComboBox->Location = System::Drawing::Point(12, 12);
this->m_objPrimaryAudioDeviceComboBox->Name = L"m_objPrimaryAudioDeviceComboBox";
this->m_objPrimaryAudioDeviceComboBox->Size = System::Drawing::Size(254, 21);
this->m_objPrimaryAudioDeviceComboBox->TabIndex = 0;
//
// m_objSecondaryAudioDeviceComboBox
//
this->m_objSecondaryAudioDeviceComboBox->FormattingEnabled = true;
this->m_objSecondaryAudioDeviceComboBox->Location = System::Drawing::Point(12, 54);
this->m_objSecondaryAudioDeviceComboBox->Name = L"m_objSecondaryAudioDeviceComboBox";
this->m_objSecondaryAudioDeviceComboBox->Size = System::Drawing::Size(254, 21);
this->m_objSecondaryAudioDeviceComboBox->TabIndex = 1;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(440, 426);
this->Controls->Add(this->m_objSecondaryAudioDeviceComboBox);
this->Controls->Add(this->m_objPrimaryAudioDeviceComboBox);
this->Name = L"Form1";
this->Text = L"FMOD Multiple Soundcard with VST";
this->ResumeLayout(false);
}
pragma endregion
};
}