c++-cli

How to use a separate .cpp file for my event function definitions in windows forms?

ぃ、小莉子 提交于 2019-12-13 12:12:00
问题 I'm having trouble defining my C++ event functions in windows forms. I want to define my event functions (example: button click) in a separate .cpp file instead of doing all the function definitions in the windows forms .h file that's already full of generated code for the windows forms GUI. I tried doing this, Declaration inside the Form1.h class: private: System::Void ganttBar1_Paint (System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e); And this is the definition inside Form1

Calling method indefinitely

痴心易碎 提交于 2019-12-13 10:28:35
问题 I want to use a .dll created with c++/cli that includes normal c code in an c# wpf project. A function of the c code needs permanent calling. This function was orginally called in an endless loop in the main function of a c command-line-application. How do I call a function permanently from a wpf c# project without interfering with the rest of the application? I guess that should be pretty easy but Im new to wpf and fairly new to .Net. 回答1: using System.Threading; Thread t = new Thread(()=>{

How to read next line in csv file on button click

筅森魡賤 提交于 2019-12-13 09:31:19
问题 I have a windows form with two butttons and a text box. My start button reads the first line in the csv file and outputs the data I want into a textbox: private: System::Void StartBtn_Click(System::Object^ sender, System::EventArgs^ e) { String^ fileName = "same_para_diff_uprn1.csv"; StreamReader^ din = File::OpenText(fileName); String^ delimStr = ","; array<Char>^ delimiter = delimStr->ToCharArray( ); array<String^>^ words; String^ str = din->ReadLine(); words = str->Split( delimiter );

C++/CLI - Textbox HideCaret - hide blinking cursor

随声附和 提交于 2019-12-13 08:11:35
问题 Is there any method to use HideCaret() .... or in general, just achieve something like described here: Prevent Blinking Cursor in Textbox but in a Managed C++ (clr) ? 回答1: If you're in C++/CLI, just call HideCaret directly, no need for DllImport . #include <windows.h> System::Windows::Forms::TextBox^ textbox1; HideCaret((HWND)textbox1->Handle.ToPointer()); 来源: https://stackoverflow.com/questions/27803394/c-cli-textbox-hidecaret-hide-blinking-cursor

Why does Visual Studio 2015 form size changes when debugging? (C++/CLI)

拥有回忆 提交于 2019-12-13 08:08:38
问题 Decided to start working on a personal project creating a C++ program with a GUI. The idea that I had in mind was to practice what I'm learning in college by implementing it on a personal project. After debugging it I noticed the size was quite off. For some reason, everything it scaling downwards when debugged. I'm guessing this has to do with Visual Studio not recognising my current screen resolution or conflict with my theme (which is an ordinary Windows 10 theme). Please let me know if

How to use templates with C++/CLI 2010?

血红的双手。 提交于 2019-12-13 07:37:49
问题 I've got following method in c#: public static T[] GetResult<T>(ulong taskId) { return GetResult(taskId).Cast<T>().ToArray(); } and I'm trying to use it in managed c++ 2010 like this: array<UrlInfo^>^ arr=Scheduler::GetResult<UrlInfo>(taskId); where I'm getting Error 3 error C2770: invalid explicit generic argument(s) for 'cli::array<Type,dimension> what am I doing wrong? 回答1: If UrlInfo is a value type, you don't want the ^ . Try array<UrlInfo>^ arr If UrlInfo is a reference type, you need a

My UI hangs when I select some area in the console

ぃ、小莉子 提交于 2019-12-13 07:24:23
问题 I log my messages to the console. But I have some interesting effect. My UI hangs when I select some messages in the console. UI will alive when I deselect all in the console. I do not like such behavior. Is it any solution? Console::WriteLine("Message"); 回答1: You're selecting text in the console. You can imagine that if the console continued outputting information it would be hard to select what you want to select, so the system pauses visible updates. If you want your application to

CLI Native objects getting stuck in gen2 and not garbage collected

妖精的绣舞 提交于 2019-12-13 07:15:03
问题 I am working on this high frequency production system. There is a C# / CLI layer which calls into a C++ library. What we are observing is that managed objects are going into generation 2 of the garabage collector and getting 'stuck'. Eventually the C# applications grind to a halt as RAM runs out. These managed objects are local objects and should have a very short lifetime. Also they are only referenced once. The C# applications are having to call .Dispose() on all their objects that hold

How do I make an custom drawn resizable container?

我只是一个虾纸丫 提交于 2019-12-13 06:34:30
问题 I have a WinForms gui application which has a number of areas to it which I'd like to custom-draw some graphics. These areas would contain controls and be resizeable. I'm currently thinking of inheriting from a TableLayoutPanel and handling onpaint messages. Does this sound like a good way to go or are there other/better options? 回答1: Any Windows Forms control has a Paint event, you don't have to derive your own class. But sure, you can, it helps partitioning the code. Just pick a base class

Create a mixed mode C++/CLI DLL

大城市里の小女人 提交于 2019-12-13 06:27:27
问题 I hope not to repeat something already asked..I search around but I haven't found something similar. I have developed a native sdk which expose some classes and interfaces. Now, I need to implement a mixed mode DLL which uses this SDK. But the following code does not compile: WrapperClass.h #pragma once #include <vcclr.h> #using <mscorlib.dll> class WrapperClass{ public: WrapperClass(); private: gcroot<Client^> m_ManagedObj; }; NativeClass.h #pragma once #include "stdafx.h" #include