c++-cli

Extract numbers from String

时光总嘲笑我的痴心妄想 提交于 2019-12-02 07:16:31
问题 I have to parse a String to create a PathSegmentCollection. The string is composed of numbers separated by comas and/or (any) whitespaces (like newline, tab, etc...), also the numbers can be written using scientific notation. This is an example: "9.63074,9.63074 -5.55708e-006 0 ,0 1477.78" And the points are: P1(9.63074, 9.63074), P2(-0,555708, 0), P3(0, 1477.78) To extract numbers I use a regular expression: Dim RgxDouble As New Regex("[+-]?\b[0-9]+(\.[0-9]+)?(e[+-]?[0-9]+)?\b") Dim Matches

Extract numbers from String

允我心安 提交于 2019-12-02 07:13:52
I have to parse a String to create a PathSegmentCollection . The string is composed of numbers separated by comas and/or (any) whitespaces (like newline, tab, etc...), also the numbers can be written using scientific notation. This is an example: "9.63074,9.63074 -5.55708e-006 0 ,0 1477.78" And the points are: P1(9.63074, 9.63074), P2(-0,555708, 0), P3(0, 1477.78) To extract numbers I use a regular expression: Dim RgxDouble As New Regex("[+-]?\b[0-9]+(\.[0-9]+)?(e[+-]?[0-9]+)?\b") Dim Matches As MatchCollection = RgxDouble.Matches(.Value) Dim PSegmentColl As New PathSegmentCollection Dim

Using Visual C++ for C++ instead of C++/CLI

人走茶凉 提交于 2019-12-02 06:02:48
I know how to program in C++ making console programs, but now I want to code programs with interfaces for Windows. MS VS 2010 makes things easy when coding C++ Windows applications with its drag & drop design system. (.net Framework) However, Visual Studio seems to use C++/CLI, which I'm unfamiliar with. Is there for an IDE which only uses C++? Is there any good IDE with an easy to use GUI designer, or can I tweak VS 2010 to not to use C++/CLI? Visual C++ is perfectly happy to not use C++/CLI syntax, in fact it works even better without it. Just set "Use of .NET Framework (/clr)" setting in

Keep the delegate argument names when compiling C++/CLI for .Net

左心房为你撑大大i 提交于 2019-12-02 05:33:51
In C# I can get Visual Studio to keep the delegate's argument names. For example if I have: public delegate void Blah(object myArg); public event Blah Foo; Then when I add a method to the event, Visual Studio UI automatically keeps the names and creates the method: void Form1_Foo(object myArg); But, if I declare a delegate in C++/CLI: public: delegate void Blah(Object^ myArg); event Blah^ Foo; it doesn't keep the names and creates a method with nonsense names: void Form1_Foo(object A_0) How can I set meaningful names to the argument in C++/CLI ? EDIT (Added ildasm results): C++ CLI event:

C++/CLI System.AccessViolationException when calling unmanaged function in managed class

a 夏天 提交于 2019-12-02 05:06:59
问题 I have a native callback function in C++, let's say something like this: void ::CallbackFunction(void) { // Do nothing } Now I have another native function: void ::SomeNativeFunction(void) { m_callback = std::tr1::bind(&::CallbackFunction, m_Tcy); // save in m_callback | m_Tcy is the class where CallbackFunction exists m_Tcy->SomeManagedFunction(m_callback); } Alright, so now I called a managed function and gave this function a native c++ function. Let's look into the managed code: // This

C++/CLI - how to open a new form and back

感情迁移 提交于 2019-12-02 05:02:08
问题 I am creating an application where the front end has to be a Windows Form using C++/CLI. The form is used for login purpose. In my form, I have a register button. On click of this button, a new form should open ( closing the login form ). I was able to achieve this by the following code: Form^ rgForm = gcnew RegisterForm; rgForm->Show(); this->Hide(); // using this->Close() was closing the application Now I want to have a cancel button on the register form, whose click should open the login

Cast native pointer to a C++\CLI managed object reference?

故事扮演 提交于 2019-12-02 04:46:18
问题 I have a callback that is called through a delegate. Inside it I will need to treat the buffer data that arrive from a record procedure. Normally in a unmanaged context I could do a reinterpret_cast on dwParam1 to get the object reference. But in a manged context how can I cast a DWORD_PTR to a managed object ref? static void WaveInProc(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) { ControlLib::SoundDevice^ soudDevice = ?cast_native2managed?(dwParam1);

How do I forward declare a delegate in C++/CLI?

99封情书 提交于 2019-12-02 04:36:38
How? The following did not work: delegate MyDelegate; ref class MyDelegate; delegate void MyDelegate; The following works for declaration: public delegate void MyDelegate(Object ^sender, MyArgs ^args); But using it as a forward declaration gives me error C3756: 'MyNameSpace::MyDelegate': delegate definition conflicts with an existing symbol RandomNickName42 This work's for me; stdafx.h: public delegate void Handler(bool isit); cli1.cpp: #include "stdafx.h" using namespace System; namespace MY { namespace Namespace { public ref class Objeks { public: Objeks() {} public: event Handler^ OnHandler

Primitive types pass template parameter between c++ and CLI

这一生的挚爱 提交于 2019-12-02 04:28:43
问题 I have a c++ templated class: template<class T> class A { void test (T temp) { } }; But i need to wrap it in CLI so it can be used in c#. Example: CLI: template<class T> ref class AWrap { private: A* a; public: void test (T temp) { a->test<T>(temp); } }; C#: Awrap blah = new AWrap(); blah<int>(3); If I make a CLI templated ref class , which call the templated c++ method, will the primitive types generate the right c++ templated code on compilation ?-> 回答1: What you are using in C# are

C++/CLI DLL namespace not found in MSVS

走远了吗. 提交于 2019-12-02 04:19:53
The big picture: what I am trying to accomplish is writing code in both C# and C++, to strike a good performance/productivity balance. It is not for code reuse reasons; I just want to be able to write new code in native C++ when it suits me, without committing to all its horrors. I have a solution with 4 projects: GUI: C# WPF interface Logic_Cs: C# DLL, high level reference implementation of game logic Logic_CLI: CLI DLL, interface between managed and unmanaged code Logic_Cpp: C++ lib with native implementation At some point, all of this was working just fine. In my GUI project I could switch