|
As posted previously it really depends on the hardware, but in general unless it is an older PC the difference will probably be neglible.
Thanks,
Sean
|
|
|
|
|
I am making a C++ program to play some mp3 files and am running into trouble. I am getting identifier not found errors. Can anyone give me some advice besides including the header?
Here is my code:
#include "fmod.h"
#include "windows.h"
#include <string>
#include <iostream>
#include <msclr\marshal_cppstd.h>
#include <conio.h>
#pragma comment (lib, "fmodex64_vc.lib")
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;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
FSOUND_SAMPLE* handle;
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ textBox1;
protected:
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::ListBox^ list;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->list = (gcnew System::Windows::Forms::ListBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
this->textBox1->Location = System::Drawing::Point(97, 23);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(518, 20);
this->textBox1->TabIndex = 0;
this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(12, 26);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(79, 13);
this->label1->TabIndex = 1;
this->label1->Text = L"Libray Location";
this->list->FormattingEnabled = true;
this->list->Location = System::Drawing::Point(15, 80);
this->list->Name = L"list";
this->list->Size = System::Drawing::Size(757, 472);
this->list->TabIndex = 2;
this->button1->Location = System::Drawing::Point(697, 571);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 3;
this->button1->Text = L"Play";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
this->button2->Location = System::Drawing::Point(616, 571);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 4;
this->button2->Text = L"Refresh";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(784, 606);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->list);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
this->PerformLayout();
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
msclr::interop::marshal_context context;
std::string standardString = context.marshal_as<std::string>(textBox1->Text);
GetAllFiles(standardString);
}
void GetAllFiles(string sPath){
WIN32_FIND_DATA FindFileData;
string sTmpPath = sPath;
sTmpPath += "\\*.*";
HANDLE hFind = FindFirstFile( sTmpPath.c_str(), &FindFileData );
if ( hFind == INVALID_HANDLE_VALUE )
return;
else {
do {
if ( ( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) {
if ( strcmp(".", FindFileData.cFileName ) && strcmp("..", FindFileData.cFileName) ) {
sTmpPath = sPath;
sTmpPath += "\\";
sTmpPath += FindFileData.cFileName;
GetAllFiles( sTmpPath.c_str() );
}
}
else
{
sTmpPath = sPath;
sTmpPath += "\\";
sTmpPath += FindFileData.cFileName;
string fileType = sTmpPath.substr(sTmpPath.length()-3, sTmpPath.length());
if(fileType == "mp3"){
String^ myTempPath = gcnew String(sTmpPath.c_str());
list->Items->Add(myTempPath);
}
}
} while ( FindNextFile( hFind, &FindFileData) != 0 );
FindClose( hFind );
}
return;
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
FSOUND_Init (44100, 32, 0);
handle=FSOUND_Sample_Load (0,"E:\\Steve\\Music\\2 Pac\\Unknown Album\\Temptations.mp3",0, 0, 0);
FSOUND_PlaySound (0,handle);
FSOUND_Sample_Free (handle);
FSOUND_Close();
}
};
Here are my errors:
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(26): error C2143: syntax error : missing ';' before '*'
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(26): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(26): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(187): error C3861: 'FSOUND_Init': identifier not found
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h (190): error C2065: 'handle' : undeclared identifier
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(190): error C3861: 'FSOUND_Sample_Load': identifier not found
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(191): error C2065: 'handle' : undeclared identifier
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h (191): error C3861: 'FSOUND_PlaySound': identifier not found
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(192): error C2065: 'handle' : undeclared identifier
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(192): error C3861: 'FSOUND_Sample_Free': identifier not found
1>c:\users\steve\documents\visual studio 2010\projects\testforms\testforms\Form1.h(193): error C3861: 'FSOUND_Close': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|
|
|
|
What do you mean "besides including the header?" Obviously you're missing a header file.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I've just started a new VC++ Form project. I understand that I can manipulate my forms through events on the generated form header file.
However, for better design, I want to be able to update the form from external controlling objects (for instance when new data is generated in the system at large).
The problem is, in the generated main file, Application::Run( gcnew <formname>() ); means that I can't send any commands through (e.g. changing text on a button) because this is constantly running until the form is closed.
How do you typically deal with this? Am I approaching this in the wrong manner?
Many Thanks in advance for your help.
|
|
|
|
|
Some more info on my setup. I'm running Visual Studio Express 2008 and I'm currently using a Windows Form Application.
I really just want to know how to update the form from outside the form (if that makes sense).
I thought this might be the answer, but I'm not familiar with properties:
http://msdn.microsoft.com/en-us/library/cakx2hdw(v=vs.80).aspx#Y360
Thanks.
|
|
|
|
|
The Run() method is creating the message queue and generating the main application window. You probably need to read up on how Windows manages messaging between windows. You can still send commands through, it's handled by the framework so you really can't "see" the message pump. You just have to define the messaging interface.
|
|
|
|
|
Good morning. I am having a challenge deriving a connection string from my App.config. It is laid out for a special way of connection to SQL Server and Teradata, and using AppSettings is not possible. I would like to query for the value using LINQ or Lamda, but I don't have a great deal of experience in either.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="UPCAppSettings">
<section name="DEVELOPMENT" type="MyCompanyProvident.iServices.Common.ConfigurationHandler.UPCAppSettingsHandler, MyCompanyProvident.iServices.Common.ConfigurationHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" allowLocation="true" allowDefinition="Everywhere"/>
<section name="PRODUCTION" type="MyCompanyProvident.iServices.Common.ConfigurationHandler.UPCAppSettingsHandler, MyCompanyProvident.iServices.Common.ConfigurationHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" allowLocation="true" allowDefinition="Everywhere"/>
</sectionGroup>
<sectionGroup name="MyCompany.Enterprise.Configuration">
<sectionGroup name="DEVELOPMENT">
<section name="MyCompany.appSettings" type="System.Configuration.NameValueSectionHandler" />
<section name="MyCompany.Enterprise.Data.Sources" type="MyCompany.Enterprise.Data.Sources, MyCompany.Enterprise, version=3.5.0.0, culture=neutral, publicKeyToken=01021d914afa5758" />
<section name="MyCompany.Enterprise.Security.ServiceAuthorization" type="MyCompany.Enterprise.Security.Authorization.ServiceAuthorizationConfigurationSection, MyCompany.Enterprise, version=3.5.0.0, culture=neutral, publicKeyToken=01021d914afa5758" />
<!-- Insert your custom sections here -->
</sectionGroup>
<sectionGroup name="PRODUCTION">
<section name="MyCompany.appSettings" type="System.Configuration.NameValueSectionHandler" />
<section name="MyCompany.Enterprise.Data.Sources" type="MyCompany.Enterprise.Data.Sources, MyCompany.Enterprise, version=3.5.0.0, culture=neutral, publicKeyToken=01021d914afa5758" />
<section name="MyCompany.Enterprise.Security.ServiceAuthorization" type="MyCompany.Enterprise.Security.Authorization.ServiceAuthorizationConfigurationSection, MyCompany.Enterprise, version=3.5.0.0, culture=neutral, publicKeyToken=01021d914afa5758" />
<!-- Insert your custom sections here -->
</sectionGroup>
</sectionGroup>
</configSections>
<MyCompany.Enterprise.Configuration>
<LOCALDEVELOPMENT>
<DEVELOPMENT>
<MyCompany.Enterprise.Data.Sources>
<DataSource key="TDConnKey" provider="Teradata" connection="Data Source=TDDEV;Database=MyProject_ddbo;Integrated Security=False;">
<CredentialStore appName="MyCompany.MyProject.DataAccess" credentialName="MyProject" />
</DataSource>
<DataSource key="SQLConnKey" provider="SqlServer" connection="Data Source=iServDev;Initial Catalog=FrameworkDB;Integrated Security=True" />
</MyCompany.Enterprise.Data.Sources>
</DEVELOPMENT>
<PRODUCTION>
<MyCompany.Enterprise.Data.Sources>
<DataSource key="TDConnKey" provider="Teradata" connection="Data Source=TDDEV;Database=MyProject_ddbo;Integrated Security=False;">
<CredentialStore appName="MyCompany.MyProject.DataAccess" credentialName="MyProject" />
</DataSource>
<DataSource key="SQLConnKey" provider="SqlServer" connection="Data Source=iServProd;Initial Catalog=FrameworkDB;Integrated Security=True" />
</MyCompany.Enterprise.Data.Sources>
</PRODUCTION>
</MyCompany.Enterprise.Configuration>
<appSettings>
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="amqmdnet" publicKeyToken="DD3CB1C9AAE9EC97" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.3" newVersion="1.0.0.3" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
Thank you, WHEELS
|
|
|
|
|
Wheels012 wrote: I would like to query for the value using LINQ or Lamda, but I don't have a great deal of experience in either.
Why would you want it in "LINQ or Lambda"? (Without using the "it looks cool" argument)
A XmlDocument could be used, just looping nodes and returning the desired value.
Bastard Programmer from Hell
|
|
|
|
|
That is a good idea. I'll give it a shot. Thank you.
|
|
|
|
|
after learning the rule of C++,i still could not write a beautiful program like MSM or QQ, what should i do ? Shall i learn MFC or others ?i want to use SDK
|
|
|
|
|
First decide which language you wish to use, and then read books, check the internet for useful resources. Take a look at some of the articles[^] here on CodeProject, you will find many useful samples and tutorials.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Those are web based chats... so you should probably learn about doing web (or cloud) based applications and their relevant tools/frameworks. You can do it with C++ as well, but at that point you're probably working at a lower level than you have to.
|
|
|
|
|
template <typename String1>
void CompareText()
{
GUESSWHAT<String1> comparator;
String1 val1 = "abc";
String1 val2 = "xyz";
ISSAME(comparator(val1, val2), true);
}
ISSAME is the macro which can takes 2 vals.
Please let me know the meaning of "comparator".What is it(Function / object / Declaration)?
Also please let me know the declaration & defination of GUESSWHAT.
|
|
|
|
|
Member 1544087 wrote: Please let me know the meaning of "comparator".What is it(Function / object / Declaration)?
Looks like a function.
Member 1544087 wrote: Also please let me know the declaration & defination of GUESSWHAT.
Looks like a macro, but since you have not provided its definition we can only guess.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I have to write defination of GUESSWHAT...
I am not having it with me.
I think, its a template. But I am not sure, how it should be declared.
|
|
|
|
|
Member 1544087 wrote: I have to write defination of GUESSWHAT...
So I guess it's your homework or college assignment, which means you should have some lecture notes that explain what is required. As I said before we cannot guess what you need to provide based on this information. The best I can suggest is that you read up on templates[^] to get some possible answers.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
hi:
i overload the operator new, codes shown as below:
void * __cdecl operator new(unsigned int size, const char *file, int line)
{
void *ptr = (void *)malloc(size);
return ptr;
}
and when i want to create a class object
CTest::CTest()
{
int a = 0;
}
CTest::~CTest()
{
int b = 0;
}
int main()
{
CTest* test = new CTest;
delete test;
return 0;
}
it is very obvious that i overload the operator new by malloc, so when i use the overloaded new operator to create a class object, the CTest's construction should not be called, while the result is complete opposite. And
my question: why the class's construction function can be called when i create it by malloc but not new?
|
|
|
|
|
I think you need to make your overload a member of the CTest class; see here[^] for further details.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Voted a 4: although you're right about the class operator new being called first, it will eventually call the global new within it, don't think the compiler allows you to dodge the constructor with the new keyword. See the link I provided below...
It's really a good question because I never tried to do this before.
|
|
|
|
|
Albert Holguin wrote: it will eventually call the global new within it
This is all explained in the MSDN link I provided in my answer.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Overloading operator new only affect how memory is allocated. The constructor of your class is always called.
By the way, it has nothing to do with C++/CLI and thus, it is in the wrong forum.
Philippe Mori
|
|
|
|
|
|
It is defined by the standard to works that way. By the way, why would you wany to override operator new. It is hard to do correctly and efficiently.
And it C++, it never a good idea to create an object without calling its constructor. Thus why you would want it that way?
Also, if you override new, then you should probably override delete also to have a matching implementation.
Philippe Mori
|
|
|
|
|
1. Can I pass the CommVariant to other function, when not created using new ?
2. Should I free it/delete expecitly some where ?
3. Is it safe ?
<pre>CComVariant comVariant;
comVariant.vt = VT_I4;
comVariant.intVal = 10;
SendComVariantToOtherFunction(comVariant);
Thanks in advance!!
|
|
|
|
|
I'm new to C++ and am running into another hicucp I'm hoping someone can help me with. I'm looking to change the opacity on a form when the mouse enters it (to 100%), and then dim it again when the mouse leaves the Windows form. I can almost get things to work, but I'm seeing oddities that I think are due to the fact that it "enters" other controls that are on the form. Here's what I've been tinkering around with:
private: System::Void MyForm_MouseHover(System::Object^ sender, System::EventArgs^ e) {
this->Opacity = 1.00;
}
private: System::Void MyForm_MouseLeave(System::Object^ sender, System::EventArgs^ e) {
this->Opacity = 0.50;
}
private: System::Void MyForm_MouseEnter(System::Object^ sender, System::EventArgs^ e) {
this->Opacity = 1.00;
}
Can someone explain to me how I can prevent my code from repeatedly reading things until the cursor leaves the entire form?
Thanks!
|
|
|
|
|