|
What is the Managed C++ !!!?
I want to know more about it and Do I must have VC++ .Net to use it or not??
Thanks
ahmed
|
|
|
|
|
How do i create a dll [roject in c++.net using the managed classes. I can do this in the standard c++ but I dont know how to do this with the new .NET framework for c++. Any help in how to do this or simply set up the project would be great -- Thanks in advance
|
|
|
|
|
How can i clear socket's incoming buffer??
|
|
|
|
|
by reading in it ...
TOXCCT >>> GEII power
|
|
|
|
|
I keep getting these errors and I can't figure out why the errors are there.
The line that is throwing these errors is this:
String * pstrDisplay;
BankAccount *pabnkAccounts __gc[];
int pintCurAccount;
pstrDisplay<<pabnkAccounts[pintCurAccount];
I am overloading the << operator like this:
// In class definition
static String *op_LeftShift( String *&, BankAccount * );
// Implementation
static String *op_LeftShift( String *&vstrOut, BankAccount *vbnkAccount )
{
vstrOut = String::Concat("Account Number: ",
vbnkAccount->GetAccountNumber().ToString()),
"\010\013");
return vstrOut;
}
Any help would be great.
|
|
|
|
|
cdmlb wrote:
Did you put
#include "iostream"
You still need to do this even if you are using MC++
I did this and there was no difference, I got the same error.
cdmlb wrote:
why not use
cout <<pabnkaccounts[pintcuraccount]<<endl;< i="">
I would do this but the BankAccount class is a managed class and I get errors when I try to use ostream in the overload it throws an error saying I can't use unmanaged code in a managed class.
cdmlb wrote:
Console.WriteLine(pabnkAccounts[pintCurAccount].ToString());
I would do something like this, unfortunately it is for school and I have to use the overload method.
I guess that I will have to keep messing around with it. I hope that I won’t have to rewrite the class as unmanaged, but I have to do what I have to do.
Thanks for your help anyway
|
|
|
|
|
Well it's weird I write managed and unmanaged code inline all the time. Maybe you could send the file so I can look closer at it.
Information Technologist
|
|
|
|
|
I could not figure out how to send it to you so I put it online. Here is a link to it:
http://chartermi.net/~reznod/problemcode.zip
The line that is giving me the errors is in 'Part123.cpp' in Part123(), the 3rd case of the switch statement.
I appreciate your help very much.
|
|
|
|
|
Hi! I've spent all day trying to figure out how to write a program to talk to a MySQL database. I'm new to the .NET framework, but it seems like it would be straightforward enough. I tried using MySQLDriverCS but it give me debug errors, something about not finding required files. Also, I haven't found a way to get the standard MySQL API working on .NET. So, is there a way to make MySQLDriverCS work for managed c++ or could someone tell me how to setup the MySQL API for Visual C++ .NET?
-- Steve
|
|
|
|
|
How would I change the data in a 6x5 char array in selected cells with a variable? i.e.
eeeeee
e
eee
e
eeeeee
How would I change the e's to g's and display the following?
gggggg
g
ggg
g
gggggg
|
|
|
|
|
using System;
namespace MyConsoleApplication
{
class MyClass
{
[STAThread]
static void Main(string[] args)
{
char[,] arrayName = new char[6,5]; //double subscripted array 6x5
//initialize array with e's since
//I don't feel like making a shape
//like you did with e's and spaces
for(int i=0; i < arrayName.GetLength(0); i++)
{
for(int j=0; j < arrayName.GetLength(1); j++)
{
arrayName[i,j] = 'e';
Console.WriteLine(arrayName[i,j]); //print to the screen
//to see if did what I wanted
//to test it out
}
}
for(int i=0; i < arrayName.GetLength(0); i++)
{
for(int j=0; j < arrayName.GetLength(1); j++)
{
if(arrayName[i,j].Equals('e')) //find only e's replace with g's
{
arrayName[i,j] = 'g';
Console.WriteLine(arrayName[i,j]); //print to the screen
//to see if it did replace
//replace all e's
}
}
}
Console.ReadLine(); //pause
}
}
}
It does work, this code will ingore all other char like spaces you made to create the shape and only replace the e's with g's, code works for any mc++, c# application type.
Information Technologist
|
|
|
|
|
Can someone give me the source code of a simple tetris in c++ language??
I have this assignment for my algorythm and programming lesson...sooner better...thank u very2 much!!
|
|
|
|
|
Hi!
Recently i downloaded an article from this page. This project was programmed in C++ with managed extensions and serves as a .NET Wrapper around a existing C++ implementation of random generators and distributions.
I added this project to my solution that consist of a C# windows application. Under VS.NET 2003 everything worked well and i could use the wrapped random generators and distributions.
Unfortunately, i had to move my solution back to VS.NET 2002. My C# windows application still works well, but the downloaded project doesn't get compiled. I receive the following errors, which i noted besides the lines that generate them:
<br />
template<class T><br />
struct ptr_helper<br />
{<br />
typedef T value_type;<br />
typedef T& reference_type;
typedef const T& rvalue_type;
static reference_type ref(T& r) { return r; }
static const T& ref(const T& r) { return r; }
};<br />
This struct is declared in a header-file of the existing C++ implementation that gets wrapped by the downloaded project.
Why can i compile this under VS.NET 2003 but not in VS.NET2002? What i can i do?
THX in advance
|
|
|
|
|
Hi, I have program written in C#. I want to use some functions from it. I have DLL, but not sure how I can call that functions from C++ application. If some one can help or direct me to the sample code.
Thanks
|
|
|
|
|
Not exactly sure. Try something like:
<br />
#using <mscorlib.dll><br />
#using <System.Windows.Forms.dll><br />
using namespace System;<br />
using namespace System::Windows::Forms;<br />
#using <MyCSharp.dll><br />
using namespace MyCSharp::MyCSharpNamespace;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
#pragma push_macro("new")<br />
return 0;<br />
#pragma pop_macro("new")<br />
}<br />
Don't forget to set Project Properties:
Configuration Properties | General | Use Managed Extensions = Yes
C/C++ | General | Debug Information Format = Program Database (/Zi)
C/C++ | Code Generation | Enable Minimal Rebuild = No
C/C++ | Code Generation | Basic Runtime Checks = Default
Which is a best guess based on Tom Archer's book:
Extending MFC Applications with the .NET Framework[^]
Sincerely,
-Ron
|
|
|
|
|
|
Did it work?
Sincerely,
-Ron
|
|
|
|
|
|
i have a mixed mode dll which defines some functions in a .def file. my unmanaged app loads the dll dynamically with a call to LoadLibrary() and calls these functions. some of my functions are called correctly, but some are not. the unmanaged app seems to be able to find all the functions, but for some reason, can't call some of the functions. anyone have an idea as to why that would be??
|
|
|
|
|
Hi, everyone!
I'm a newbie in MC++ and Win32 API programming. I want to create a Bitmap object with an image of a Windows.Forms form. So far I've written the following code:
<br />
Bitmap *De3DFormView::GetWindowBitmap(Form *pForm)<br />
{<br />
System::Drawing::Graphics *pGraph = Graphics::FromHwnd(pForm->Handle);<br />
int pSrc=pGraph->GetHdc().ToInt32();<br />
<br />
HDC destDC;<br />
HBITMAP destBmp;<br />
DWORD err;<br />
<br />
destDC = CreateCompatibleDC((HDC)pSrc);<br />
destBmp = CreateCompatibleBitmap((HDC)pSrc, pForm->Width, pForm->Height);<br />
<br />
SelectObject(destDC, destBmp);<br />
<br />
SendMessage(HWND((int)pForm->Handle), WM_PRINT, WPARAM(destDC), PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN | PRF_ERASEBKGND);<br />
<br />
Bitmap *pB = Image::FromHbitmap(destBmp);<br />
<br />
pGraph->ReleaseHdc(pSrc);<br />
pGraph->Dispose();<br />
<br />
return pB;<br />
}<br />
When I run it, I get the following exception "ArgumentException" with message "hdc". Debugging shows that this error occurs after the "SendMessage" call.
The other thing is that when I step through the "destDC = CreateCompatibleDC((HDC)pSrc);" line, I notice that destDC has "undefined value".
Can you tell me what I am doing wrong?
Regards,
Serge (Logic Software)
|
|
|
|
|
The search function I have isn't working, possibly because of the scope of the while & if functions or that I am using the wrong functions.
Please see if a different [U]search [/U] or maybe if the [U]code[/U] needs changing, Thank you button.
[code]
#include <iostream.h> //Pre Processor Directives
#include <fstream.h> //Libary for Input funcitons
#include <iomanip.h> //Input/Output manipulation libary
#include <string.h>
void main()
{
ofstream file("Database"); //Create a new file
file.open("Database");
char* name[9];
name[0] = NULL;
name[1]="HP4p";
name[2]="HP5L";
name[3]="HP6p";
name[4]="Cannon2A";
name[5]="Cannon3B";
name[6]="Epson2";
name[7]="Epson3";
name[8]="Epson4A";
float cost[9];
cost[1]=32.99;
cost[2]=24.99;
cost[3]=30.00;
cost[4]=23.45;
cost[5]=31.99;
cost[6]=25.00;
cost[7]=30.00;
cost[8]=27.99;
int quantity[9];
quantity[1]=100;
quantity[2]=50;
quantity[3]=75;
quantity[4]=30;
quantity[5]=80;
quantity[6]=10;
quantity[7]=25;
quantity[8]=30;
char name8[13]="Cartridge";
char cost8[11]="£00.00p";
char quantity8[12]="Quantity";
{
for (int x = 1; x < 8; x++)
file<<name[x]<<' '<<cost[x]<<' '<<quantity[x];
}
file.close(); //close the file
int num=0,x;
char sought[15]; //Declare Variables
cout<<"Display all records press '1' "<<"Do a Search press '2' "<<" '0' to Quit "<<endl;
cin>>num;
if (!num==0)
{
if (num==1)
{
cout<<"Total Items in stock \n"<<endl<<endl;
ifstream file("Database",ios::in); //ios::in for input from the file
cout<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name8;
cout<<setw(10)<<setfill(' ')<<setiosflags(ios::right)<<cost8;
cout<<setw(12)<<setfill(' ')<<setiosflags(ios::right)<<quantity8<<endl;
for (int x = 1; x < 8; x++)
{
cout<<endl<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<cost[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<quantity[x];
}
}
cout<<endl<<endl<<"Display all records press '1' ";
cout<<"Do a Search press '2' "<<" '0' to Quit "<<endl;
cin>>num;
if (num==2)
{
cout<<endl<<"To search by the printers make type in the name e.g HP4p: Type 'N' for no more"<<endl;
cin>>sought;
ifstream file("Database"); //open file for input FROM file
//while(!file.eof())
//{ //file.seekg(0); //set file pointer to first character
if (strcmp(sought,"N")!=0)
{
delete [] name[0]; //it is safe to call delete [] on NULL pointer.
name[0] = new char[strlen(sought)];
strcpy(name[0],sought);
x=8;
while (strcmp(name[x],sought)!=0)
x--;
if (strcmp(name[x],sought)==0)
{
cout<<endl<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<cost[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<quantity[x]<<endl;
}
else
{
cout<<"No such item in stock"<<endl<<endl;
}
file.close();
cout<<"Display all records press '1' ";
cout<<"Do a Search press '2' "<<" '0' to Quit"<<endl;
cin>>num;
}
}
}
}[/code]
|
|
|
|
|
Hello people !
It seems that either my Visual Studio .Net 2003 is missing a critical component or then I am simply too dumb to use it..
I'm trying to write a MC++ Web Service using some of the tutorials available here on CodeProject, but in the list of available projects under "Visual C++ Projects", I only have "ASP.NET Web Service", "ATL Server Web Service" and "Windows Service (.NET)". Other project types refer to different applications alltogether (MFC, empty projects etc)
Which one of these is considered as _the_ Managed C++ Web Service ? I believe it's the ASP.NET type, but I'd like to have a confirmation.
Following the same route, and by following Chris Maunder's example on writing a web service with C#, I was unable to find the "Web Service" project under "Visual C# Projects".. The only options available are "ASP.NET Web Application", "ASP.NET Web Service" and "Web Control Library", among the standard ones.
Any clues ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
You want the ASP.NET Web Service. It creates a skeleton web service for you which runs under IIS.
|
|
|
|
|
I have been trying to get the search facility below to work but it throws an error because of the memory being allocated I think.
Please Please take a look at the code and see you can do anything...Much appreciated. Buttons
#include <iostream.h> //Pre Processor Directives
#include <fstream.h> //Libary for Input funcitons
#include <iomanip.h> //Input/Output manipulation libary
void main()
{
ofstream file("Database"); //Create a new file
file.open("Database");
char* name[9];
name[1]="HP4p";
name[2]="HP5L";
name[3]="HP6p";
name[4]="Cannon2A";
name[5]="Cannon3B";
name[6]="Epson2";
name[7]="Epson3";
name[8]="Epson4A";
float cost[9];
cost[1]=32.99;
cost[2]=24.99;
cost[3]=30.00;
cost[4]=23.45;
cost[5]=31.99;
cost[6]=25.00;
cost[7]=30.00;
cost[8]=27.99;
int quantity[9];
quantity[1]=100;
quantity[2]=50;
quantity[3]=75;
quantity[4]=30;
quantity[5]=80;
quantity[6]=10;
quantity[7]=25;
quantity[8]=30;
char name8[13]="Cartridge";
char cost8[11]="£00.00p";
char quantity8[12]="Quantity";
{
file<<name<<' '<<cost<<' '<<quantity;
}
file.close(); //close the file
int num=0,x;
char sought[15]; //Declare Variables
cout<<"Display all records press '1' "<<"Do a Search press '2' "<<" '0' to Quit "<<endl;
cin>>num;
while(!num==0)
{
if (num==1)
{
cout<<"Total Items in stock \n"<<endl<<endl;
ifstream file("Database",ios::in); //ios::in for input from the file
//while(!file.eof())
cout<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name8;
cout<<setw(10)<<setfill(' ')<<setiosflags(ios::right)<<cost8;
cout<<setw(12)<<setfill(' ')<<setiosflags(ios::right)<<quantity8<<endl;
for (int x = 1; x < 9; x++)
{
cout<<endl<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<cost[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<quantity[x];
}
}
cout<<endl<<endl<<"Display all records press '1' ";
cout<<"Do a Search press '2' "<<" '0' to Quit "<<endl;
cin>>num;
if (num==2)
{
cout<<endl<<"To search by the printers make type in the name e.g HP4p: Type 'N' for no more"<<endl;
cin>>sought;
ifstream file("Database"); //open file for input FROM file
//file.seekg(0); //set file pointer to first character
while (strcmp(sought,"N")!=0)
{
strcpy(name[0],sought);
x=9;
while (strcmp(name[x],sought)!=0)
x--;
if (strcmp(name[x],sought)==0 && x>0)
{
cout<<endl<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name;
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<cost;
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<quantity<<endl;
}
else
{
cout<<"No such item in stock"<<endl<<endl;
}
}
file.close();
cout<<"Display all records press '1' ";
cout<<"Do a Search press '2' "<<" '0' to Quit"<<endl;
cin>>num;
}
}
}
|
|
|
|
|
I had to add #include <string.h> to get it to compile.
strcpy(name[0],sought);
That statement is probally where the problem is. name[0] is an unintialized pointer, so when you try to copy a null terminated string into it you will be accessing a random location in memory.
One solution is to initalize it to something.
name[0] = new char[15];
You will have to remember to release that memory before you are done.
delete [] name[0];
Another solution is to just assign that pointer to point directly to the sought string.
name[0] = sought;
This seems a little strange, but it is pretty effecient. Also, you have to worry about freeing it later.
The next problem I get is with this statement.
while (strcmp(name[x],sought)!=0)
The reason is that x is initialized to be 9, but the highest possible index for name array is 8. Rember, indexing starts at 0. So, change x=9; to x=8;
There are a couple other problems with that code, but this will at least get you past the memory problems.
|
|
|
|