|
If they all spend their time reading The Mythical Man-Month four people may not even be enough...
PS: have been reading some Joel-on-Software lately, so I couldn't join in, sorry.
|
|
|
|
|
marcusab wrote: I would like to copy the data content of pDataByte to QByte
Here's two ways:
array<Byte> ^pDataByte = gcnew array<Byte>(4);
pDataByte[0] = 0x41;
pDataByte[1] = 0x42;
pDataByte[2] = 0x43;
pDataByte[3] = 0x44;
unsigned char QByte[4];
pin_ptr<Byte> p = &pDataByte[0];
memcpy(QByte, p, 4);
Marshal::Copy(pDataByte, 0, IntPtr(QByte), 4);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you very very very much , you got me going in the right direction, see my answer to Navaneeth for more info.
Almost, pDataByte is a System::Object^ {System.Array}, not an array<unsigned char=""> {Length = 0x4} as with QByte. See debug info:
Name Value Type
pDataByte {System.Array} System::Object^
[0x0] 0x41 ‘A’ unsigned char
[0x1] 0x42 ‘B’ unsigned char
[0x2] 0x43 ‘C’ unsigned char
[0x3] 0x44 ‘D’ unsigned char
QByte {Length=0x4} unsigned char[]
[0x0] 0x00 ‘’ unsigned char
[0x1] 0x00 ‘’ unsigned char
[0x2] 0x00 ‘’ unsigned char
[0x3] 0x00 ‘’ unsigned char
So I get compilation error:
<br />
error C2665: 'System::Runtime::InteropServices::Marshal::Copy' : none of the 16 overloads could convert all the argument types<br />
|
|
|
|
|
marcusab wrote: pDataByte is a System::Object^ {System.Array}, not an array
An array IS a System.Array, but I missed your declaration - sorry about that!
You need the cast
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
By the way, how do I create the variable pDataByte (now I recevie it from an external DLL).
I would like to do someting like this:
System::Object ^pDataByte = gcnew System::Object(System::Array<<System::Byte>>(4));
To get this:
Name Value Type
pDataByte {System.Array} System::Object^
[0x0] 0x00 ‘’ unsigned char
[0x1] 0x00 ‘’ unsigned char
[0x2] 0x00 '’ unsigned char
[0x3] 0x00 ‘’ unsigned char
|
|
|
|
|
Never mind ...
System::Object ^pDataByte = gcnew array<System::Byte>(4);
Again, thank you very much
|
|
|
|
|
Why not use the strong type instead of a System::Object^ ?
array<Byte> ^pDataByte = gcnew array<Byte>(4);
If you must use System::Object^...
System::Object ^pDataByte = gcnew array<Byte>(4);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks again, you are the man
|
|
|
|
|
Hi, I can't find any decent example on how to create a DialogBox using C++/CLI and on how to deal with the different responses triggered by the diffent buttons being pressed.
I've created graphically the DialogBox (form2) which has 2 buttons "A" and "B" but I can't understand how I can pass different values to the main form (form1) when each button is selected. Is it possible to do it without creating a new class. How?
Any example code would be highly appreciated.
|
|
|
|
|
J_E_D_I wrote: I can't understand how I can pass different values to the main form (form1) when each button is selected.
You can add public properties and/or methods to the form1 class that can be used
like any other class properties/methods.
You could also use events if a publisher/subscriber scenario is more appropriate.
This is basic C++ and not particular to the UI...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
J_E_D_I wrote: but I can't understand how I can pass different values to the main form (form1) when each button is selected.
As Mark points out, these forms are classes so the same thing applies to them as any class. That said from a Design, Principles and Best Practices perspective, it is not advisable to have cohesion between UI views. See the Design Pattern Model View Controller[^].
|
|
|
|
|
Set some Button.DialogResult value for those buttons that should close the dialog and return something.
|
|
|
|
|
Recently i have converted my project to support Common Language Runtime Support (/clr).
After this i notice linking takes long time.
Can we reduce this speed issue?
|
|
|
|
|
I'm very interested in hearing about any solutions you might find. I have a very large MFC application where I want to use .NET WPF.
I have been told that one should not enable the CLR switch for an entire project, but only for the source files that need to interact with .NET code.
Also did the linker time become slow by just enabling the CLR switch, or are you comparing linker times in VC6 with VS2005/VS2008 ?
|
|
|
|
|
No. After CLR conversion only i takes long time to link.
|
|
|
|
|
You could use #pragma unamanged[^] at the top of your unamanaged source files.
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Yes. Isn't always such a shock at what useful things one finds in the documentation. It's almost like it would be a good idea to constantly be using it.
|
|
|
|
|
They should have called it #pragma fast_linking then.
|
|
|
|
|
I'm porting a WindowsControlLibrary solution from DotNet2003 to 2005 and I get the following error
Error 1 error C2691: 'Mcs600CTL::Mcs600CTLControl::flotArray' : a managed array cannot have this element type c:\work\net2005\mcs600ctl\Mcs600CTLControl.h 148
this use to compile on 2003 without any problems
typedef float flotArray __gc[];
public: __event void Mcs600_Raw_Spektra_Ready( flotArray mySpektra); line 148
I also get this error
Error 2 error C2664: 'Mcs600CTL::Mcs600CTLControl::raise_Mcs600_Raw_Spektra_Ready' : cannot convert parameter 1 from 'float __gc[]' to 'Mcs600CTL::Mcs600CTLControl::flotArray __gc[]' c:\work\net2005\mcs600ctl\Mcs600CTLControl.h 1002
__raise Mcs600_Raw_Spektra_Ready(sampleSpectrum); Line 1002
regards,
-dan
|
|
|
|
|
You already have a thread for this question here[^]
Why are you starting new ones when you have not even replied to the people that were helping you in the first thread. That is not really how this site rolls, I suggest you get your act together if you want people from this site to help you.
|
|
|
|
|
Wow dude - that thread you linked to is so old I can't even view the responses.
How did you find that?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Easily[^]
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
He was joking. He was the guy replying to the thread.
|
|
|
|
|
|
I see Diplomacy is not one of your strong suites!!
|
|
|
|