c++-cli

How can I make sure a ListView item always resizes to show all rows?

I have a panel which contains a TableLayoutPanel which itself contains a number of ListViews and Labels. What I'd like is for each list view to resize to fit all of it's contents in vertically (i.e. so that every row is visible). The TableLayoutPanel should handle any vertical scrolling but I can't work out how to get the ListView to re...

Identifying memory leaks in C++

I've got the following bit of code, which I've narrowed down to be causing a memory leak (that is, in Task Manager, the Private Working Set of memory increases with the same repeated input string). I understand the concepts of heaps and stacks for memory, as well as the general rules for avoiding memory leaks, but something somewhere is ...

Pass an argument by reference in C++/CLI so re-assignment affects the caller

Probably this is not a difficult question, but I am always a little bit confused on how to treat String type as an argument in Visual C++. I have the following to functions: void function_1(String ^str_1) { str_1 = gcnew String("Test"); } void function_2() { String ^str_2 = nullptr; function_1(str_2); } After calling function_1...

List View doesn't render items in Details view

VariableBox = gcnew ListView(); VariableBox->Font = ScriptEditorOptions->FontSelection->Font; VariableBox->Dock = DockStyle::Fill; VariableBox->BorderStyle = BorderStyle::Fixed3D; VariableBox->BackColor = ScriptEditorOptions->BCDialog->Color; VariableBox->ForeColor = ScriptEditorOptions->FCDialog->Color; VariableBox->DoubleClick += gcnew...

How can be Interop of MSXML Node in C++/CLI as XMLTextWriter or related XML Usability

Hello, I have some native code which generates native XML node of MSXML. I need that root node in C++/CLI to be use as XMLTextWriter or in any form of XML in C++/CLI. Is there any interop available for MSXML Node for using in C++/CLI. Regards Usman ...

How can I read CPU temperature on an Embedded XP install from a C++/CLI app?

I've read of some WMI solutions which are able to read the temperature of the CPU. I've tried this and it doesn't appear to work for Windows XP Embedded running on an Intel Atom based board. Is there a library or some other solution out there which would work? ...

Should a managed class that wraps a DirectSound interface be IDisposable?

I'm writing a managed wrapper around DirectSound. (It's a simple partial wrapper that solves my specific problem and nothing more. Don't tell me about NAudio or whatever.) Should a managed class that wraps IDirectSound8 be IDisposable and why? Same question about IDirectSoundBuffer8. ...

Variable assignment in 1st condition and using same variable in 2nd condition Well defined?

Is this well defined? Streamreader ^reader = gcnew Streamreader("test.txt"); String ^line; while ((line = reader->ReadLine()) != nullptr && line != "") { //do stuff } I believe that I read somewhere that it is not guaranteed that the assignment is executed before the 2nd conditional. It may be that I'm wrong or that this just ap...

vtable error. "vtable for ETRun", referenced from:

Hi, I have an object called Run. I can instantiate in header of a class. But, when i try to do the same .cpp file the above error was popped out. vtable error. "vtable for Run", referenced from: __ZTV5Run$non_lazy_ptr in Para.o string Para::name() { Run* newRun = new Run; return mName; } how can i get out of this...

Looking for any good(and free) cross-platform CLI parsing library for a command line utility

I am currently working on a CLI utility which I feel can be improved a lot by adding a framework. Basically the utility revolves around lots of command line syntax AND parsing the output. Currently the code is scattered all around with lots of individual inhouse run() and readFromRunOutput() calls with hardcoded CLI arguments. For exa...

Warning C4564 when building C++/CLI project that consumes strong-typed dataset

After upgrade to VC++ 2010, Warning C4564 is raised (method defines unsupported default parameter) when building a C++/CLI project that consumes a strong-typed dataset from a C# project. ReadersManager.cpp(311): warning C4564: method 'SetNewRecord' of class 'System::Data::DataTable' defines unsupported default parameter 'action' 3> ...

Problem with Visual Studio 2010 DataTips in a mixed C++/CLI assembly

I've recently switched to using Visual Studio 2010. I've got a problem where the DataTips (debugger tooltips) for STL types aren't loading correctly. For example, in the following code: int test( const std::string& inString ) { std::string aString( "Hello, World!" ); return aString.compare( inString ); } I don't get the exp...

VB.net to C++/CLI: How do I import a VB.net dll into C++/CLI?

I would like to import a VB.net dll into C++/CLI. I am having trouble referencing my dll. I have tried to find tutorials but with no luck, in particular, I usually find how to import managed libraries directly into native code through COM. I would like to import an existing VB.net dll into my C++/CLI project. Do I require a header file...

C++/CLI how to.

Hi all, I am learning C++/CLI and stuck with a problem. I have a header file that looks like typedef struct _DATA_INFO { WORD ONE WORD TWO WORD THREE } DATA_INFO public ref class ManagedDataInfo { DATA_INFO* info; public ManagedDataInfo() { info=new DATA_INFO(); } ...

How do I get the non-maximised window size of a form?

I'm trying to save my the state of a System::Windows::Forms::Form when my application shuts down. I can record the window's size, position and window state without any issues but if the window was maximised when it was closed the ::Size member records the maximised size of the window. Is there any way to record the non-maximised size or...

How can I programmatically determine the size of my desktop?

I'm trying to save / restore the window size, state and position of a System::Windows::Forms::Form and want to make sure that if the window was previously on another monitor and the app is started up when only a snogle monitor is available, that it puts itself somewhere on-screen. So how can I determine the current desktop size and whet...

C++/CLI Explicitly Load Managed DLL at runtime (the equivalent of LoadLibrary for Unmanaged)

Problem 1: Is there a way to explicitly load a library at runtime instead of at compile time in C++/CLI. Currently I am using the .NET "Add Reference" at compile time. I would like to explicitly load a managed dll. Is there the .NET equivalent of LoadLibrary? Update: Thanks to Randolpho Assembly::LoadFrom example from MSDN Assembly^ ...

Adding two path names in VC++

String^ Source = System::IO::Directory::GetCurrentDirectory()+ "\\DeleteFolder.exe\"" ; String^ Destination = "C:\\Windows\\DeleteFolder.exe"; pin_ptr<const wchar_t> WSource = PtrToStringChars(Source); pin_ptr<const wchar_t> WDestination = PtrToStringChars(Destination); Is there any problem with the code above, i am unable to get the s...

How to check a "NULL object reference" in Managed C++ ?

Hi there, I come across some MC++ code like this: __gc class ClassA { Puclic: ClassB GetClassB(); } __gc class ClassB { Public: int Value; } int main() { ClassA^ a = gcnew ClassA(); ClassB^ b = a->GetClassB(); int c = b->Value; } Isn't it important to check whether b is NULL before access to its value? I trie...

Automated version number in a VC++/CLI app using innosetup to distribute.

I maintain a small app which is built in VC++ 2008 (a .net app) which I distribute using innosetup. Currently I manually update the version number in the header of the main app: static String^ m_version = "1.1"; static String^ m_build = "1"; The software puts this together internally to report v1.1.1 in this case. To do a release I t...