|
Thanks John
|
|
|
|
|
I have a HeaderFile MyProject_Datas.h
public ref class MyUsefulDatas
{
blah...blah...blah...
public: static System::Void Item_Name( System::Object^ Sender, System::Windows::Forms::KeyEventArgs^ e) {
blah...blah...blah...
}
public: static System::Void Party_Name( System::Object^ Sender, System::Windows::Forms::KeyEventArgs^ e) {
blah...blah...blah...
}
};
And now from my Form2 - textBox2 I would like to declare
textBox2->KeyDown += gcnew KeyEventHandler(MyUsefulDatas, &MyUsefulDatas::Party_Name); ????????
Iam not getting the above line........
Also I would like to learn same statement, how to use in "delegate" statement like the below.....????
textBox2->KeyDown += delegate { .....???????? }
Thanks...
|
|
|
|
|
After spending my whole day I found the crazier worth of the word, what is "static" ...
Also after removing the word "static" from the above declaration it works well..
Let it be useful to the searchers....
public ref class MyUsefulDatas
{
public: System::Void Party_Name( System::Object^ Sender, System::Windows::Forms::KeyEventArgs^ e) {
blah...blah...blah...
}
};
MyUsefulDatas^ MyUseDta=gcnew MyUsefulDatas;
textBox2->KeyDown += gcnew KeyEventHandler(MyUseDta, &MyUsefulDatas::Party_Name);
Thanks...Thanks...
modified 16-Apr-12 10:53am.
|
|
|
|
|
Can I help to convert the next C++/CLI code to Visual Studio 2002 Managed C++?
bool IsPrinterOk(String ^printerName)
{
bool bResult=false;
HANDLE hPrinter;
IntPtr pPrinterName=Marshal::StringToHGlobalUni(printerName);
WCHAR *pChar=(WCHAR *)pPrinterName.ToPointer();
if(::OpenPrinter(pChar,&hPrinter,NULL)==0)
return false;
DWORD bytesNeeded;
::GetPrinter(hPrinter,2,0,0,&bytesNeeded);
PRINTER_INFO_2 *pf=(PRINTER_INFO_2 *)GlobalAlloc(GPTR,bytesNeeded);
if(::GetPrinter(hPrinter,2,(LPBYTE)pf,bytesNeeded,&bytesNeeded)!=0)
if(pf->cJobs==0 && pf->Status==0)
bResult=true;
GlobalFree(pf);
ClosePrinter(hPrinter);
return bResult;
}
What changes must be made in the code?
Thanks.
|
|
|
|
|
goncri wrote: What changes must be made in the code?
Try compiling it and see what errors or warnings you receive.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Are you sure you want 2002 Managed C++?
The pre-CLI managed C++ syntax was a failed experiment - the syntax was available only for a short time and it was quickly superceded by C++/CLI (even C++/CLI is not commonly used).
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hi,
I like to convert the following codes from c# to VC++2010. Thanks for the helps.
Actually the codes for dataGridView - Enter Key movement from one cell to another cell [like a tab key...]
public class MyDataGrid : DataGridView
{
protected override bool ProcessDialogKey(Keys keyData)
{
Keys key = keyData & Keys.KeyCode;
if (key == Keys.Enter)
{
base.OnKeyDown(new KeyEventArgs(keyData));
return true;
}
else
{
return base.ProcessDialogKey(keyData);
}
}
}
Thanks 
|
|
|
|
|
public ref class MyDataGrid : DataGridView
{
protected:
virtual bool ProcessDialogKey(Keys ^keyData) override
{
Keys ^key = keyData & Keys::KeyCode;
if (key == Keys::Enter)
{
DataGridView::OnKeyDown(gcnew KeyEventArgs(keyData));
return true;
}
else
{
return DataGridView::ProcessDialogKey(keyData);
}
}
};
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hi,
Iam very new in VC++2010. And at first I create a new project, and I changed the name
Form1() as MyMainForm()...
And after it shows error MyProject.cpp
#include "stdafx.h"
#include "MyMainForm.h"
blah...blah...blah...blah..
Application::Run(gcnew MyMainForm());
From the bove line it shows error C2061: Syntax error : Identifier 'MyMainForm'
So how to solve this problem...
Thanks For Startup...
|
|
|
|
|
Let it be usueful to someone like me..
Just I renamed the file - Form1 as MyMainForm in entire solution....
Then the error gets clear...
Thanks & Regards,
PARAMU
|
|
|
|
|
This is fairly standard; if you change the name of any object, then you must change it everywhere.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I was wondering, when coding C++ in WinXP, if there is any performance difference (CPU cycles) between "float" (32bit) and "double" (64bit) variables.
Thanks.
|
|
|
|
|
This is the wrong forum for this question because it has nothing to do with C++/CLI.
Use the regular MFC forum instead.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
It depends on the hardware that you have as well as the software implementation. You would need to run some tests to check.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Someone voted you down... +5
|
|
|
|
|
Thanks, but not to worry, there are 1-voters all over the place.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
|
Like Richard said, it will vary according to hardware (64bit systems will handle 64bit number a whole lot faster than 32bit systems) and whatever your software happens to be doing with it. For example, if you're using a 64bit number to keep track of some number of iterations, I suspect increased latency would be minimal (if noticeable at all).
|
|
|
|
|
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
|
|
|
|
|