c++-cli

Boost Preprocessor library for generating a set of types based on a list of basic types e.g. PointI32, PointF32 etc. in C++/CLI

♀尐吖头ヾ 提交于 2019-12-01 13:45:35
I am trying to figure out how to use the Boost.Preprocessor library http://www.boost.org/doc/libs/release/libs/preprocessor to unfold a "generic" type for different specific types. Below I will ask this for a simple point class example. Given: struct Point##TYPE_SUFFIX_NAME { TYPE X; TYPE Y; // Other code }; I want to generate this type for different basic (POD) data types e.g.: PointF32, PointF64, PointI32 etc. where PointF32 would be: struct PointF32 { float X; float Y; }; That is, based on a list of types: short, int, long, float, double etc. I want to "unfold" the above type for these.

What is the simplest way to display (and change) an image resource on a WPF dialog (using C++/CLI)?

好久不见. 提交于 2019-12-01 13:41:16
I have a C++/CLI GUI application and I want to display an image as a visual aid for the user to see what step in a procedure they're at. This image will need to be changed each time the user selects the new step. Currently I'm using a picture box and have an image loaded from the disk at run time. So there are a few things I need to know here: Is a picture box the best thing to use for this purpose or is there another control that would better suit? How do embed the images in the executable and load them from there instead of a file that exists on disk. How do I load a new image (I'm guessing

How do I pass variable arguments from managed to unmanaged with a C++/CLI Wrapper?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 12:51:17
To implement a params(variable arguments) functionality in the managed domain, we do the following in c++/cli such as: funcManaged(int n, ...array<int>^ variableParams) I'm dumbfounded on how to pass this to the unmanaged domain that takes in variable arguments. funcUnmanaged(int n, ...) I tried to pass the array in, but it ended up badly (access violations, junk data, etc). //where unmanagedVariableParamsArray is an int array funcUnmanaged(int n, unmanagedVariableParamsArray); Resources suggest to create a va_list and pass that around, vFuncUnmanaged(int n, va_list vl) But how do I create the

How to convert String^ to char array [duplicate]

非 Y 不嫁゛ 提交于 2019-12-01 11:37:24
Possible Duplicate: Need to convert String^ to char * I have been looking so long for this solution but I can't find nothing specific. I work in Visual Studio C++, windows forms app. I need to convert String^ value into char array. I have stored value from TextBox in String^ : String^ target_str = targetTextBox->Text; // lets say that input is "Need this string" I need to convert this String^ and get output similar to this: char target[] = "Need this string"; If it is defined as char target[] it works but I want to get this value from TextBox . I have tried marshaling but it didn't work. Is

Mixing managed and unmanaged C++ code?

我只是一个虾纸丫 提交于 2019-12-01 11:24:02
I have a couple specific questions regarding mixing managed C++ with unmanaged C++: If I leave out ref and value in a class/struct declaration, does that automatically make the class/struct unmanaged? Or do I still need to include the #pragma unmanaged and #pragma managed directives? How compatible are unmanaged and managed types? For example, I can have an unmanaged object in a managed class, right? Can I pass an unmanaged class/struct to a managed function (ie. pass a std::string to a managed function)? Thanks for your help, Alex You can't have hybrid types (native class containing a managed

Mixed-mode C++/CLI app not shutting down CLR correctly

早过忘川 提交于 2019-12-01 10:30:54
问题 My mixed-mode MFC application is creating false memory leaks because the CRT doesn't have time to shut down before the MFC dll is shut down. I have a very simple little app that shows the problem: #include <windows.h> #include <iostream> struct LongTimeToDestroy { ~LongTimeToDestroy() { std::cout << "Will get called!" << std::endl; Sleep(3000); std::cout << "Won't get called!" << std::endl; } }; LongTimeToDestroy gJamsUpTheCRT; int main() { } Compile with cl.exe /clr test.cpp . When run, you

Boost Preprocessor library for generating a set of types based on a list of basic types e.g. PointI32, PointF32 etc. in C++/CLI

你离开我真会死。 提交于 2019-12-01 09:47:42
问题 I am trying to figure out how to use the Boost.Preprocessor library http://www.boost.org/doc/libs/release/libs/preprocessor to unfold a "generic" type for different specific types. Below I will ask this for a simple point class example. Given: struct Point##TYPE_SUFFIX_NAME { TYPE X; TYPE Y; // Other code }; I want to generate this type for different basic (POD) data types e.g.: PointF32, PointF64, PointI32 etc. where PointF32 would be: struct PointF32 { float X; float Y; }; That is, based on

How to convert String^ to char array [duplicate]

泪湿孤枕 提交于 2019-12-01 09:38:33
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Need to convert String^ to char * I have been looking so long for this solution but I can't find nothing specific. I work in Visual Studio C++, windows forms app. I need to convert String^ value into char array. I have stored value from TextBox in String^ : String^ target_str = targetTextBox->Text; // lets say that input is "Need this string" I need to convert this String^ and get output similar to this: char

Seemingly inappropriate compilation warning with C++/CLI

我的未来我决定 提交于 2019-12-01 08:57:12
问题 I'm playing with a C++/CLI application that talks to my Isis2 (C# .NET) library. In the code below I get the error "Warning 3 C4538: 'cli::array ^' : const/volatile qualifiers on this type are not supported". I highlighted the line that throws this. I'm baffled: this doesn't have an array, nor does it use const or volatile! Any suggestions? // CPlusPlus.cpp : main project file. #include "stdafx.h" #using <IsisLib.dll> using namespace Isis; using namespace System; void GotNewView(View^ v) {

C++/CLI Wrapping a Function that Returns a std::shared_ptr

匆匆过客 提交于 2019-12-01 08:23:48
I'm currently wrapping a C++ class with C++/CLI for .NET interoperability following the standard process of holding a native pointer in a managed class. In one instance, I have a native class that has a function like: std::shared_ptr<BaseChannel> channelData(const int RunNumber); I have already begun creating a wrapper class for BaseChannel . However, if I pass the raw pointer to the constructor of the managed class, there are no guarantees on the lifetime of the object being pointed to by the managed class. I.e. the shared_ptr could go out of scope and the object will get deleted and the