K
K
Kirill H2017-07-27 20:36:20
C++ / C#
Kirill H, 2017-07-27 20:36:20

Third party classes as a field in Windows Forms CLR C++?

Good evening! In the evening I was digging in the studio and decided to create a simple project for myself. The hitch appeared when writing the UI.
Initial data:

  • Static lib
  • CLR project with form

It seems like a trivial task, but it was not there. As I understand it, all this crap that makes C ++ work with .NET to work with forms is something between it and C #. With all these ^ instead of *, and obscurantist gcnew instead of spiritual new.
I wanted to connect my class from lib to the header file of the form. Connected libu, included directories, everything is wise. Only now he swears, he says:
a member of a managed class cannot be of a non-managed class type

I tried to shove it there as a static field, as a pointer, a link, through this beauty ^, but nothing and how. At best, it falls out at runtime when my class is instantiated in the form constructor.
I understand that all this nonsense is just the nuances of the platform itself, but the Internet does not give clear answers to the question:
How to instantiate a third-party class in the form class with a private field?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
John_Nash, 2017-07-28
@John_Nash

Everything is clearly written. You cannot mix managed and non-managed classes.
Rather, it's a little different. Inside the managed class, you can create non-managed objects. On the contrary, no.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question