A member of a non-managed class cannot be a handle

I'm creating CLR application with forms in C++. I tried to make main class which will have window and other stuff as variables. But window variable (form) got an error which says "A member of a non-managed class cannot be a handle". Any help would be great, thanks. Here is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include "Window.h"

namespace SMSALENalozi {

	class SMSALENalozi {

	private:

		Window ^window; //error

	public:

		SMSALENalozi() {

			window = gcnew Window();

		}

	};

}

Window.h is header which has Window class which inher. from form.
Last edited on
Well that is one of the rules of .NET. A native class can't have a handle to a managed class.
One way to solve it would be to create a managed class.
Try this:
1
2
3
4
5
6
7
8
9
10
public ref class SMSALENalozi 
{
private:
   Window ^window; 
public:
   SMSALENalozi() 
  {
     window = gcnew Window();
  }
};

Thank you very much :)!
Topic archived. No new replies allowed.