Windows Controls or .NET objects as Global Variable in Visual C++
I'm Writing a C++ Class. I want to keep a global variable in System::Windows::Form::Control type or a .NET managed objects. I want to process something on this global variable. But Visual C++ is not allowed this.
Returning Error is: "global or static variable may not have managed type"
May be this error in开发者_JAVA百科terest Garbage Collector.
How I solve this problem?
use a non managed type like std::string
For a control, you could store the Handle (HWND) in your global variable and get the control back when you need it. For other managed objects, I don't know. Do they have an identifier that allows doing the same thing ?
精彩评论