Until now, I have been writing either native console applications in C++, or .NET Windows Forms applications in C#. I now want to start creating a user interface for my C++ programs, and so I have started trying out C++ with Windows Forms. I use Visual Studio 2008.
So, I started an empty CLR project. The project has a Windows Form, Form1, and a class to act as an "engine" for the whole program, called Engine. Engine contains an instance of Form1. In my main loop, I created an instance of Engine - which in turn should create an instance of Form1 - but it failed to compile, telling me that "mixed types are not supported".
It seemed to me that Form1 is, by default, managed by the garbage collector, and as such cannot be a member of a native class.
So, to try to solve this, I started another project, using the Windows Forms project wizard. This automatically loads up a form in the main loop. I gave the Form an instance of the Engine class as a member variable. However, on running the program, I again was told that "mixed types are not supported".
Am I right in thinking that, if I am writing a .NET program using Windows Forms, then all of my classes - included the user-defined classes - also need to be managed by .NET?
It looks I need to specify that my user classes should be managed by the garbage collector, rather than by myself....would this work? And how can I do this?
Bookmarks