I am trying for the first time to use Windows Forms from C++/CLI but mixing it with my unmanaged code base.
Even after reading some articles on passing values between the two I am still a little confused.
Say I have an unmanaged header file that declares:
Now I have an unmanaged .cpp that does this:
int __stdcall RunManagedOptionsForm(Options& options);
Then in my managed file I have:
int __stdcall RunManagedOptionsForm(Options& options)
OptionsForm\\^ form = gcnew OptionsForm();
options.text= form->text; //What to do here?
options.value = form->value;
I have seen code like:
String\\^ s = gcnew String("sample string");
IntPtr ip = Marshal::StringToHGlobalAnsi(s);
const char* str = static_cast\(ip.ToPointer());
Console::WriteLine("(managed) passing string...");
NativeTakesAString( str );
Marshal::FreeHGlobal( ip );
But I am not sure how to apply it in this situation?
Also if I play around with managed code that creates std::string's etc and pass that to unmanaged code is that dangerous?