c++-cli

How to use System::String::Split with a split of three characters?

断了今生、忘了曾经 提交于 2019-12-25 01:58:05
问题 namely, I want to split by a sequence of three white spaces, and then split again by a newline. I tried doing it, but it doesn't work: array<wchar_t>^ separator = {' '}; array<String^>^ QandA = x->Split(separator ); Anyone? 回答1: System.String.Split() contains an overload that takes an array of String as a delimiter. So make a new array with the one element " /n/r" (or is it /r/n.. I can never remember), and use that as your delimiter. 回答2: Regex::Split should work with complex delimiters,

Loop doesn't update listboxes until it is done iterating

丶灬走出姿态 提交于 2019-12-25 01:26:46
问题 I have a loop that takes file name from a listbox, performs a system() call, then moves that filename to another listbox. Problem is, it doesn't move the filenames over one at a time, but waits until the entire loop is finished and moves them all at once. What would I do to get it to perform how I want it to? the loop: for each( String^% file in filename ) { int x = convert( file ); lbComplete->Items->Add( lbFiles->Items[0] ); // place the completed file lbFiles->Items->Remove( lbFiles->Items

Copying control components

邮差的信 提交于 2019-12-25 00:46:54
问题 I have a C++/CLI project which has a child form with some control components. I would like to copy all the control components with their codes on a new Tab control on the main form. How can I do that? 回答1: You can select all of the controls in the designer (hold down the Shift key to make multiple selections), and then cut and paste them to their new location: Ctrl + X , Ctrl + V Alternatively, you can open up the *.Designer file that is generated automatically by the Windows Forms designer

Making Thread-Safe Calls to labels in Windows Forms Controls

大城市里の小女人 提交于 2019-12-24 20:15:36
问题 I am making a small app in Visual C++ in Microsoft Visual Studio where I am collecting data in a thread and displaying the information in labels in a Windows Form. I am trying to follow this Article/Tutorial on how to make the calls to the labels thread safe: http://msdn.microsoft.com/en-us/library/ms171728(VS.90).aspx. The example shows how to output text to one text box, but I want to output to many labels. When I try I get the error: error C3352: 'void APP::Form1::SetText(System::String ^

SendKeys::Send, going berserk

天大地大妈咪最大 提交于 2019-12-24 17:25:36
问题 I am trying to make updates to two linked TextBox es. I disable events in one and then send keystrokes using eg SendKeys::Send("A"); having first given it focus: texBox2->Focus(); texBox2->KeyDown -= gcnew KeyEventHandler(this, &Form1::texBox2_KeyDown); SendKeys::Send("A"); texBox2->KeyDown += gcnew KeyEventHandler(this, &Form1::texBox2_KeyDown); It almost works but goes totally mental instead repeating the character (I daren't look to check which exact key because I'm frantically

Make sort using delegates

跟風遠走 提交于 2019-12-24 13:00:03
问题 I'm try to make a sort delegate in C++/CLI, but, when I try to compile I recive this erro: >app.cpp(256): error C3374: can't take address of 'Program::AnonymousMethod1' unless creating delegate instance >app.cpp(256): error C2664: 'void System::Collections::Generic::List<T>::Sort(System::Comparison<T> ^)' : cannot convert parameter 1 from 'System::Object ^(__clrcall *)(Program::teste1,Program::teste1)' to 'System::Comparison<T> ^' > with > [ > T=Program::teste1 ^ > ] > No user-defined

String^ to LPCTSTR in VC++2010 (Windows form application)

烈酒焚心 提交于 2019-12-24 12:30:31
问题 How to convert System::string^ in to LPCTSTR ? As my requirement is to clone a file using function CopyFile , it works fine if i give Fix name (OldFile.jpg and LatestFile.jpg) to its parameters ( below Code: Works Fine ) LPCTSTR in_f,out_f; in_f = _T("d:\\Old.jpg"); out_f = _T("d:\\Latest.jpg"); CopyFile(in_f,out_f,false); above code clone the Old.jpeg in to a Latest.jpg but when i trying to give name (Latest.jpg) which is coming out from some String it won't create file ( below Code: NOT

.NET deletes pinned allocated buffer

ぐ巨炮叔叔 提交于 2019-12-24 12:08:07
问题 I have the following code to allocate buffer uns16 m_rawBuffer = new uns16[m_rawBufferSize]; pin_ptr<uns16> ptrAcqBuffer = m_rawBuffer; Although it is pin_ptr from time to time GC modifies ptrAcqBuffer. From the document I see A pinning pointer is an interior pointer that prevents the object pointed to from moving on the garbage-collected heap. That is, the value of a pinning pointer is not changed by the common language runtime. This is required when you pass the address of a managed class

Returning an int array in C++/CLI to c# .NET

百般思念 提交于 2019-12-24 11:26:43
问题 I'm using a C++/CLI wrapper to call a c++ library from c# .NET. While this particular code "works," I suspect that I'm doing something wrong with respect to memory. (I run into problems after running this code about 20 times in a row.) c# side: public void ExportModelToImage(int[] myImage, int imageWidth, int imageHeight) { View.ExportModelToImage(ref myImage, imageWidth, imageHeight); } C++/CLI side: void ExportModelToImage(array<int>^% myImage, int imageWidth, int imageHeight) { if (myView(

Wrapping C callback in C++/CLI

血红的双手。 提交于 2019-12-24 11:09:59
问题 I have a static C library where I have non static call back function. The Client program that register this callback gets Video data from camera . Now I am writing Wrapper( DLL ) for this in C++/CLI.This Wrapper Dll will be used in C# application. How to Implement the callback in C++/CLI so that C# code can register it and gets the video data from it. 回答1: In C++/CLI, you can have static functions (with native C signature, which can work as a callback from a C library), calling managed