private: System::Void btn_entrar_Click(System::Object^ sender, System::EventArgs^ e) {
string btn_texto = txt_login->Text->ToString();
MessageBox(NULL, "Hello!", btn_texto.c_str(), MB_OK | MB_ICONEXCLAMATION);
}
I'm creating a windows forms application normally in Visual C++ Studio 2008 Professional, I added a click function (by double clicking in the button on the design mode) so I wrote the code inside the function it generated.
it generated 2 errors:
Error 1:
error C2440: 'initializing' : cannot convert from 'System::String ^' to 'std::basic_string<_Elem,_Traits,_Ax>'
Error 2:
error C2872: 'MessageBox' : ambiguous symbol 1> could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winuser.h(7374) : int MessageBox(HWND,LPCTSTR,LPCTSTR,UINT)' 1> or
'c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::MessageBox'
I'm creating in C++ on Visual Studio 2008 Professional at Windows 7 and the project under .NET Framework 3.5
Someone know how do I fix this? I looked it up all over but couldn't find a solution. I hope I gave enough information. Thanks in advance.
@edit Example Given by Cody Gray
System::String btn_texto = txt_login->Text->ToString();
System::Windows::Forms::MessageBox(NULL, "Hello!", "HI", MB_OK | MB_ICONEXCLAMATION);
Errors Gotten
error C3149: 'System::String' : cannot use this type here without a top-level '^' error C2661: 'System::Windows::Forms::MessageBox::MessageBox' : no overloaded function takes 4 arguments
So I solved the first error by adding ^ after System::String being like this:
System::String^ btn_texto = txt_login->Text->ToString();
but the second error wasn't fixed, and by the way, how would I add the "btn_texto" content in the MessageBox Function? Thanks!