|
NULL question:
1. Use zero instead of NULL: m_szUser != 0
2. Or, include the header file 'tchar.h' which defines 'NULL'.
Event question:
__delegate void SaySomethingHandler(String *message);
__gc class EventSource
{
public :
__event SaySomethingHandler* OnSayingSomething;
Void SayHello(Void)
{
OnSayingSomething(S"Hello!");
}
};
__gc class EventReceiver
{
public :
Void Hello(String *message)
{
Console::WriteLine(S"Event Receiver: {0}", message);
}
};
int _tmain(void)
{
EventSource *evtsrc = new EventSource();
EventReceiver *evtrcv = new EventReceiver;
evtsrc->OnSayingSomething +=
new SaySomethingHandler(evtrcv, &EventReceiver::Hello);
evtsrc->SayHello(S"Hello!");
return 0;
}
String Concatenation:
// The '+' operator does not work with strings.
// Use 'String::Concat'
String *fname = S"John";
String *lname = S"Smith";
String *name = String::Concat(lname, S",", fname);
|
|
|
|
|
Thanks for the response. I'd actually started using Concat, but it's nice to know that I did the right thing.
- monrobot13
|
|
|
|
|
I write a class derived form CDialog class under managed C++, the compiling is passed but it doesn't run the code is :
private: System::Void button1_Click(System::Object * sender,
System::EventArgs * e)
{
CDisplay dddd ; ////CDisplay derived from CDialog class
dddd.DoModal();
}
why?
|
|
|
|
|
meet a debug asserting failed at dddd.DoModal();
|
|
|
|
|
What are the chances that an application written by mixing managed and unmanaged C++ being ported to a different platform like Mono. The application is developed using /CLR option and has some portions written in managed C++ which uses functionality in .net. Can this application be ported to *nix platforms using Mono.
I understand that Mono has some bindings with WineLib which means that all win32 api's would work, but does that mean that the above app will work.
I'm confused with the above scenario, any insights are welcome
thanks in advance
Cheers,
Kannan
|
|
|
|
|
I'm re-writing a DLL in managed C++ which holds multiple vectors (arrays) of floating point data (Single's). In 6.0 with MFC I used to do this:
class CCommonDataFile : public CObject
{
....
private:
CTypedPtrArray<cptrarray, float*=""> m_dataColumnArray;
....
}
so I'd have an array of pointers to float (float vectors) and would just allocate a block of memory on the heap for them and read in data from a file. To access the 3rd number in the second column, I would do this:
CCommonDataFile * cdf = new CCommonDataFile();
...
float fVar = *(cdf->m_dataColumnArray[2] + 3);
I'm really puzzled with Managed arrays in C++. How can I get the same effect? Which is to say, how can I store float vectors in an array? Is there some way to create, say, a managed array of managed arrays of Singles?? Or a managed array of pointers to managed arrays of Singles? It seemed so much simpler in the old C++. Any suggestions would really be appreciated.
Thanks,
Mark.
Mark Malin
(00==[||]==00)
|
|
|
|
|
|
Thanks. Very helpful link
Mark.
Mark Malin
(00==[||]==00)
|
|
|
|
|
Hi,
I wrote down a post some weeks ago but I can't find it so I'm sorry of having opened another one. The problem is that I'm trying to exctrat some information (like codec name, lenght, width, ecc. ecc.) from an avi files. Actually I can do everything but the codec information. After having read from www.fourcc.org and some from msdn.com (http://msdn.microsoft.com/library/default.asp?url=/library/EN-US/multimed/mmstr_1xf6.asp)
, I've understood that I have to use vfw32.h library. I can exctrat only the information that an avi's codec is:
Stream Info:
Type Codec
vids divx
How can I match the information divx to the exact versione?? Moreover, How can i distinguish from divx an xvid?? Do I have to create a structure with all the existent codec inside??
Well, it's all ... I wanna thank you everyone is going to answer me.
Francesco
|
|
|
|
|
You need to map the FourCC code (the vids divx bit) to a playback codec capable of playing it. Look on doom9.org[^] for a possible list.
<a TITLE="See my user info" href=http:
|
|
|
|
|
uhm, maybe it wasn't specified...I don't want to play a divx or an avi file, I just want to save some information about it (like lenght, width, codec) ... What do u mean in the sentence: You need to map the FourCC code (the vids divx bit)
???
thx
|
|
|
|
|
I suggest then you look at either VirtualDubs or Emule's source code as both of them displays that info to the user. Cant be that hard
<a TITLE="See my user info" href=http:
|
|
|
|
|
Just started with .net and i seem to be to dumb to figure out how to convert a string to integer. Hepl pls. thx
|
|
|
|
|
Look at the System::Convert class and it's ToInt32 methods...
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
Hi!
I'm writing a Managed C++ class library to be used by a C# client, and I have a method which prototype should look like that from C#:
MyClass.Method(string Param1, out int Param2);
Problem is, I do not clearly understand how to declare an "out" parameter in Managed C++. I tried a pointer-on-int, as I used to do in COM with the [out] attribute, but it doesn't work (IntelliSense on the C# side wants an int* too!)
I could use a reference of course, like that:
public __gc class MyClass
{
public:
void Method(System::String __gc *Param1, int &Param2) {... }
}
Not sure it works though and then the C# prototype would probably become "ref int Param2".
Is there any clever solution to this?
R/
|
|
|
|
|
ralfoide wrote:
public __gc class MyClass
{
public:
void Method(System::String __gc *Param1, int &Param2) {... }
}
The purpose of a ref parameter in C# is where the callee function assigns the value, which is exactly what your void Method(System::String __gc *Param1, int &Param2) function allows to happen to Param2 .
-Nick Parker
|
|
|
|
|
I beg to differ, but my understanding is that a "ref" is used when the called function will modify the value. An "out" seems preferable if the called function is just returning parameters.
My sample prototype was of course simplified. My function returns several parameters, and rather than returning a struct I prefer to use out parameters.
Example of C# prototype I want:
MyClass.MyMethod(string inValue, out int Param1, out int Param2, out int Param3);
So far I got it to work using "ref" if I declare the Param1..3 above using int __gc * in MC++:
This MC++ real prototype in the class library:
MyClass::MyMethod(System::String __gc* inValue, int __gc* Param1, int __gc* Param2, int __gc* Param3);
is seen like this from the C# client:
MyClass.MyMethod(string inValue, ref int Param1, ref int Param2, ref int Param3);
Ideally I'd like out parameters. If not possible, well too bad
R/
|
|
|
|
|
|
Not sure if this will help much, but I think that ref and out perform pretty much the same job, they just set a different kind of contract.
When using out you are effectively saying that the method is responsible for initialising and setting the contents, whereas with ref the calling code is responsible.
What happens if you try and use the out keyword from the C# code? Does the compiler throw up an error?
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
|
|
|
|
|
Why don't you use something like
void foo2( [out] short *value);
|
|
|
|
|
I'm trying to use managed C++ - I know this is the wrong forum but I get no response in the C++ forum.
I'm trying to use old C style structures to read in structured blocks of data from a file and am having no luck. For instance, here's my structure:
[StructLayout(LayoutKind::Explicit)]
__value struct PRE_HEADER
{
public:
[FieldOffset(0)]Byte fileType;
[FieldOffset(1)]UInt32 timeStamp;
[FieldOffset(5)]Int16 numIndexes;
[FieldOffset(7)]Byte padding;
};
Is there some way to read this in, maybe with streams like so:
PRE_HEADER ph;
int blocksize = sizeof(ph);
Byte tmpBuf __gc[] = new Byte __gc[blocksize];
FileStream* fs = File::Open(blah, blah, blah...);
fs->Read(tmpBuf, 0, blocksize);
And then somehow cast "tmpBuf" to be a PRE_HEADER type so I can access the members like you used to be able to do in C/C++??? These managed streams need to have a managed Byte buffer. I tried doing the following:
ph = reinterpret_cast<pre_header>(tmpBuf);
but the compiler isn't happy. I've tried different ways to create the variable "ph" on the managed heap, but because I have a "struc" there's no "new" operator, which I think is causing the unresolved external link errors looking for operator new().
There MUST be some way to do this. It's all so easy with C++ streams. You just make a buffer and pass it to the Stream::Read() function and cast it as your data type and away you go.
Thanks for any help - I"m pulling my hair out with this...
Mark.
|
|
|
|
|
|
Nick.
I tried dynamic_cast but I get a compiler error saying "invalid target type for dynamic cast" (with the capital p
I also tried reinterpret_cast and I get this error:
error C2440: 'reinterpret_cast' : cannot convert from 'unsigned char __gc[]' to 'PRE_HEADER'
I realize a managed array isn't going to be a block of memory - but I can't believe they've left us out in the cold when it comes to this kind of thing. For me it's been the main-stay of my file i/o for data collection because it doesn't tie the file to any language (i.e. through serialization stuff).
Mark.
Mark Malin
(00==[||]==00)
|
|
|
|
|
|
A managed C++ program executes under the .net runtime, so all the rules that apply for normal .net apps, also apply for an application written in mc++, but it gets interesting when you mix both managed and unmanaged code.
If you want to know more on garbage collection/clr, check out msdn, it has tons of docs. on that subject.
Cheers,
Kannan
|
|
|
|