|
Well, yeah, I do, but I come to this forum regularly to point people who obviously have no idea what MC++ is in the right direction. This forum seems (rightly) to be a ghost town, so I reckon a lot of people who would get answers quickly, don't because they mistakenly post here.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi guys,
I've implementing a simple class that creates a mutex and release it in the destructor (finalize), but everytime the application is closing a ObjectDisposedException is thrown. Source code here:
public __gc class SingleInstance
{
public:
SingleInstance(String *mutexName) {
m_mutex = new Mutex(false, mutexName);
}
virtual ~SingleInstance(void) {
if (m_mutex)
m_mutex->ReleaseMutex(); <--- !exception here!
}
public:
bool IsAnotherInstanceRunning() { return !m_mutex->WaitOne(10,true); }
private:
Mutex *m_mutex;
};
Can anyone of you tellme why this is happening? m_mutex is not supposed to be already disposed! Should I avoid dispose of m_mutex object? How?
Regards and thanx in advance,
Francesco
|
|
|
|
|
The problem I am having deals with wrapping an unmanaged C++ class which uses iostream and sends output to cout and then using the managed class in C#. When I make a method call on this class, I get the following error:
*** Exception! ***
Method: std.basic_ostream<char,std::char_traits<char> >* std.operator<<<struct std::char_traits<char=""> >(std.basic_ostream<char,std::char_traits<char> >*, SByte*)
Message: Object reference not set to an instance of an object.
When I replace the cout call with a call to printf, I do not get an error.
Here is the corresponding code. Thanks for the help or direction where I can get help.
USimple.h
#pragma once
__nogc
class USimple
{
public:
void PrintIt( );
};
USimple.cpp
#include "stdafx.h"
#include <iostream>
//#include <stdio.h>
#include "MSimple.h"
#include "USimple.h"
void USimple::PrintIt()
{
std::cout << "Hello, World" << std::endl;
// printf( "Hello, World\n" );
}
MSimple.h
#pragma once
#include "USimple.h"
using namespace System;
public __gc class MSimple
{
private:
USimple __nogc* m_pUSimp;
public:
MSimple( );
~MSimple();
void PrintIt( );
};
MSimple.h
#include "stdafx.h"
#include "USimple.h"
#include "MSimple.h"
MSimple::MSimple( )
{
m_pUSimp = new USimple( );
}
MSimple::~MSimple()
{
delete m_pUSimp;
}
void MSimple::PrintIt( )
{
m_pUSimp->PrintIt( );
}
Class1.cs
using System;
namespace CsSimple
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
try
{
MSimple simple = new MSimple( );
simple.PrintIt( );
}
catch( Exception e )
{
Console.WriteLine( "\n*** Exception! ***" );
Console.WriteLine( "Method: {0}", e.TargetSite );
Console.WriteLine( "Message: {0}", e.Message );
}
Console.WriteLine( "Press enter to exit" );
Console.Read(); // Wait for enter pressed to end programme
}
}
}
Thanks again,
John Stedman
|
|
|
|
|
hi all there, i want a code that help me to insert any file type in a rtf file, i need to insert by code not drag drop by mouse so plzzzzzzzzzzzzz help me .......
Thanks alot
Metal Man
|
|
|
|
|
Try asking in the C++ forum.
Isn't rtf rich text format ? How can you insert 'any file type' into a text file ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hi,
from reading the subject title... its easy... but what i really want to do is this:
say for example...
int a = 1;
int b = 2;
int number = a + b;
int number is therefore 3
HOWEVER... what i want it to do is...
to make int number 12 instead of adding it and making 3. i want the two ints together so it forms an int number of 12.
does anyone know how to do this in c++ please? something to do with strings?
thank u very much.
|
|
|
|
|
Seeing as you're asking in the MC++ forum, just call the ToString() method on the numbers a and b, and you'll get a string which you can convert back into a number.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Another, old school, method is using good ol' sprintf / atoi combo
int nNum1 = 1;
int nNum2 = 2;
char caTempBuf[10];
sprintf(caTempBuf, "%d%d", nNum1, nNum2); //concatination here
int nConcatinated_Number = atoi(caTempBuf);
that should work.
When the going gets tough... write a computer program to do the thing for you
|
|
|
|
|
Or, if you wanted something really old school (and kind of limited) you could do something like the following:
<br />
int a=1, b=2;<br />
char[3] c;<br />
c[0] = a + '0';
c[1] = b + '0';
c[2] = '\0';
cout << c << endl;<br />
but, like I said, this is kind of limited if you're doing anything with bigger or negative numbers.
Democracy for the USA!
|
|
|
|
|
int a = 1;<br />
int b = 2;<br />
int number;<br />
std::stringstream ss;<br />
ss << a << b;<br />
ss >> number;
|
|
|
|
|
Hi all,
I am doing my first setup project for the addin I wrote and can't solve following problem.
I want to deploy an addin for Visual studio. So I need to look in registry for the HKLM\SOFTWARE\Microsoft\VisualStudio\7.X\InstallDir (where 7.X is 7.0 or 7.1) and take it into MyPATH0 and MyPATH1 variables. For the installed version(s) I need to make TARGETDIR to MyPATH0\..\..\\Vc7\VCWizards.
I have no idea how to solve this. Setup wizard seems to have very simple logic, so how can I program in the wizard
"
1.TAKE REGISTRY KEY XX\7.0 into VAR
2. If success Make VAR+AAA to the TARGET DIR
3.Install
4.TAKE REGISTRY KEY XX\7.1 into VAR+AAA
5. If success Make VAR to the TARGET DIR
"
Thank you very much for your help,
Boni
|
|
|
|
|
Im having a little trouble storing the outputs in an array. while the compiler is running i can get the correct output, but cant set up the array for using the results later on. any help would be greatfully appreciated.
What I want in the array is time_of_arrival results from the following function;
CComplexVector process_the_ray(CRay3d a_ray,int m)<br />
{ <br />
CComplexVector result ; <br />
double the_distance ; <br />
int i ; <br />
double length;<br />
<br />
<br />
result = inc_field( (a_ray.listnode(0)).listpoint(),(a_ray.listnode(1)).listpoint(),m ) ; <br />
the_distance = (a_ray.listnode(1).listpoint() - a_ray.listnode(0).listpoint()).abs() ; <br />
<br />
<br />
for( i = 1 ; i < a_ray.non() - 1 ; i++) { <br />
if( a_ray.listnode(i).listtype() == 1) <br />
result = calculate_reflection(result, a_ray.listnode(i-1) , a_ray.listnode(i), a_ray.listnode(i+1) , the_distance) ; <br />
<br />
if( a_ray.listnode(i).listtype() == 2) <br />
result = calculate_transmission(result, a_ray.listnode(i-1) , a_ray.listnode(i), a_ray.listnode(i+1) , the_distance) ; <br />
<br />
<br />
the_distance += (a_ray.listnode(i+1).listpoint() - a_ray.listnode(i).listpoint()).abs() ; <br />
<br />
} <br />
<br />
<br />
length=the_distance;<br />
cout<< "length is:" <<length<<endl;<br />
<br />
time_of_arrival=(length/c);<br />
<br />
cout<<"time_of_arrival:"<<time_of_arrival<<endl;<br />
<br />
return result; <br />
<br />
}
|
|
|
|
|
How do I overload that operator?
I wrote a ref class, and I want to implement [] operator. I tried various ways, without success.
What is the exact synrax?
I Hate MC++.
Thanks.
|
|
|
|
|
I don't use MC++, but the operator signatures for operator[] in
most flavors of C++ is typically as follows:
// return element for read/write
T& operator[](int index);
// return element for read-only
const T& operator[](int index) const;
Hope that was what you were looking for.
|
|
|
|
|
How can I detect a incoming phone call and display the number on the screen using C++ program
If possible send a code
Jack
|
|
|
|
|
Brilliant.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
|
Hi!
I'm working with Borland C++ Builder 6 and i need to get the mirror of a text; it means that a string has to be flipped. In other words, i don't need only that the characters of a string change order ('mirror' becomes 'rorrim'), but also the single font must be flipped (not using a mirrored font). How can i obtain that? I tried by inverting the order of the pixels of the Canvas in which the text is drawn, but in this way the software get too slow.
Please, give me help!
Thanks a lot
Bye
|
|
|
|
|
Borlard cannot compile managed C++.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I'm new to managed C++ and I am looking at MCppWrapper, one of the 'Cross-Language Samples' in the help for Visual Studio.NET. It shows how managed C++ can wrap unmanaged C++ and then be used by C#.
Two questions:
- The unmanaged code returns a dynamically allocated char*, which the managed C++ casts to a String*, which the C# uses as a String object. At what point (and how) does the char* become a String object with its properties set, e.g. Length?
- How and when does this char* allocated by unmanaged code get freed? Can the Garbage collector do that?
Thanks!
John Frank
|
|
|
|
|
|
Thank you very much for your reply!
However, from all that I can tell from the code, this is not a case of PInvoke. I am new to Managed C++ so I may be missing something, and I realize that it is hard to answer my questions without having seen the code. I have used PInvoke with C# to use standard Windows DLLs, and MSDN seems to indicate that I would need to do the same thing in C++:
' [C++] Use the DllImportAttribute to identify the DLL and function. Mark the wrapper method or function with extern "C". '
None of this is apparent -- is this somehow happening implicitly?
Regarding the second question: Are you saying that the garbage collector is freeing memory that is allocated by an unmanaged process?
Thanks again!
John Frank
|
|
|
|
|
Hello everyone!
First time I ask a question here but have read many articles and learned a lot....
I have a problem with managed C++ and the Application class, I want to use Application::CommonAppDataPath but the only answer I get is "D:\Documents and Settings\All Users\Application Data\\\1.0.0.0" and I have tried changed the items (alredy present) in assemblyinfo.cpp but to no help.
But I can't figure out what I am doing wrong...
Are there other propeties that need to be changed/added?
Something else I am doing wrong (something is it obviously )?
greetings:
Mårten
|
|
|
|
|
I have been trying for kicks to write a Managed C++ dll to wrap the creation of a system tray icon and those notification balloons.
However I have noticed that the stucture of NOTIFYICONDATA does not match with the version posted on MSDN and is missing the various variables required to to create a the balloons. I have tried updates my platform sdk to no avail. Any suggestions where I could find the correct one or would I have to define it myself?
|
|
|
|
|
Please,
How create a Printer Port Monitor??
I need to create this.
Please help me!!!
raf-sp
|
|
|
|