c++-cli

array<Byte>^ TO unsigned char* :: Marshall class - Interop Issue

Hi, I wanted to convert array< Byte>^ to unsigned char*. I have tried to explain what i have done. I donot know how to proceed further. Please show me the right approach. I am using MS VC 2005. //Managed array array<Byte>^ vPublicKey = vX509->GetPublicKey(); //Unmanaged array unsigned char vUnmanagedPublicKey[MAX_PUBLIC_KE...

Is there any direct way to do what pin_ptr does?

Can the behaviour of pin_ptr be achieved directly in C++/CLI? For example, is it possible to write CLR code directly, something like asm for native apps? An example of what I would like to do is a wrapper for a pin_ptr (impossible because of the restrictions on pin_ptrs). class WrappedPtr { public: explicit WrappedPtr(String^ s) ...

.NET GUI - C# vs C++/CLI

Hi guys, I'm writing a small app that requires a few listboxes, buttons, textboxes. It'll be linked with Boost, MySQL, etc. C++ static libs. The project requires win32 functions. I figure Winforms will be fine (MFC and CodeJock require too much time). So C++/CLI seems perfect for the job. Just use standard C++ along side the GUI. Then ...

Why C# is not allowing non-member functions like C++

C# will not allow to write non-member functions and every method should be part of a class. I was thinking this as a restriction in all CLI languages. But I was wrong and I found that C++/CLI supports non-member functions. When it is compiled, compiler will make the method as member of some unnamed class. Here is what C++/CLI standard ...

How to convert vc++(ex: IListPtr ) pointer to std::list ??

Hi Can any body help me in converting Interface Pointer to list variable in vc++ since i am getting the error while typeconversion error 2440 "type cast" :cannot convert from '_bstr_t' to 'std::list<_Ty>' so any one plz help me.... Thanks in advance. Reply: i Hav done liki this in C# com i have done like List Disp() { List...

Insert text into table in Microsoft Word (C++, Visual Studio 2005)

Hello. I've managed to figure out how to create a Word document using PIA and C++ in Visual Studio. But I can't figure out how to write text to the table cells. I would appreciate any help. Thanks EDIT: Thanks for your comments. I've finally managed to figure it out: I can loop through the cells in the table, select the cells with Cell...

C++/CLI switch on String

In other .NET languages such as C# you can switch on a string value: string val = GetVal(); switch(val) { case "val1": DoSomething(); break; case "val2": default: DoSomethingElse(); break; } This doesn't seem to be the case in C++/CLI System::String ^val = GetVal(); switch(val) // Compile error { // Snip } Is there a sp...

How to return List from c# and use it in vc++ through com

Hi How to return List from c# method and Use the List return values in c++ can u give guidance how to do it?? I going like following way my complete scenario: in c# DemoLib.cs usng System;using System.Collections.Generic; public interface IDiscover { void GetList1(); String GetList2(); List<string> GetList3(); }; namespace Dem...

How do I use ArrayList in C++?

Hi, I have created a method who's return type is an ArrayList instead of List. And I have created a COM component. How do I access this ArrayList in my main application which is in C++? ex: ArrayList fun1() { ArrayList al = new ArrayList(); al.Add("one"); al.Add("two"); return al; } So how do I handle this retu...

Documenting C++/CLI library code for use from c# - best tools and practices?

I'm working on a project where a c++/cli library is being used primarily from a c# application. Is there any way to make the code comments in c++/cli visible to c# intellisence within visual studio? Assuming there isn't, what would be the best way to document the c++/cli code to enable its easier use from c# (and within c++/cli of cour...

WriteableBitmap unavailable?

I've discovered what may be the perfect answer to a question on buffered drawing, but for some reason my version of VS2008 doesn't seem to have a WriteableBitmap? I've tried including the relevent namespaces as per the documentation: using namespace System::Windows::Media; using namespace System::Windows::Media::Imaging; But that just...

Can C++/CLI be used to call .Net code from native C++ applications?

I've done the other way around (Calling pure C++ code from .Net) with C++/CLI and it worked (for the most part). How is the native->c++/cli direction done? I really don't want to use COM interop... ...

How do I make a generic class to represent a range using .NET?

I've been trying to make a generic class to represent a range of values but am having some difficulty trying to work out what I'm missing (the compiler comlplains about a missing copy constructor, but all the implementations I've tried have failed). So my questions: Is there a Range template somewhere I've missed to avoid me reinventin...

SystemEvents::PowerModeChanged Problem

Whats in my project(C++/CLI): - dllimport some un managed dlls - wndproc is override in the form - Treads are there - Times used - I used notify icon so used myForm->Hide() and myForm->Show() I used the following line but MyMainForm::onPowerModeChanged method never fires... SystemEvents::PowerModeChanged += gcnew PowerModeChangedEv...

Calling C# from C++, Reverse P/Invoke, Mixed Mode DLLs and C++/CLI

As I understand it I can use reverse P/Invoke to call C# from C++. Reverse P/Invoke is simply a case of: Create you managed (c#) class. Create a c++/cli (formerly managed c++) class library project. Use this to call the managed c# class (presumably via a reference). Call the c++/cli code from native c++. Questions: Is this correc...

Class Template in C++/CLI

Hello, I formed class template that represent two dimensional array : template<class T> class Array2D { protected: public: T *data; const unsigned rows, cols, size; Array2D(unsigned r, unsigned c) : rows(r), cols(c), size(r*c) { data = new T[size]; } ~Array2D() { delete data; } void...

C++ calling C# options

Hi We have native Win32 C++ code and a set of C# assemblies which we wish to call from the C++ code. I summaries our optios as: Use COM. The C# code would need to be decorated with additional attributes (GUID, COMVisible). The C# assemblies would need to be registered regasm and would then be available to the native C++ code via CO...

Looking for a faster-than-GDI solution for rendering dynamic data plots

I've written a simple GDI-based data plotter using C++/CLI but it's not particularly fast (some basic profiling indicates it's the rendering to screen that's the problem). Is there any way to enable hardware acceleration for a UserControl or is there a .net interface for direct3D? ...or are there some other options I could consider. We...

How to I pass a checkbox value by reference with CLI?

I have a GUI app written in C++/CLI which has a load of configurable options. I have some overloaded functions which grab values from my data source and I'd like to connect my options to those values. So here's a couple of data retrievers: bool GetConfigSingle(long paramToGet, String^% str, char* debug, long debugLength); bool GetConfi...

"for each" statement in C++/CLI

array<int> ^ints = gcnew array<int>{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; for each(int i in ints) if(i % 2 == 0) Debug::WriteLine("Even\n"); else Debug::WriteLine("Odd\n"); Why does the above fail to compile? It works fine if I use a for(int i; ...) or if I enclose the if-else within braces. I know that the manual cl...