The code below is from my form.. I declared a string GLOBALLY.. Then upon FormLoad, It inserts values for the string... When I do button click, the string is blank.. Why is it blank? Shouldnt the Values from FormLoad Event be in it? :
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
public:
System::String^ StringF; //<-- Tried to declare my string globally..
and then I did:
public: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
Form1::Visible = false;
Query ^ F = gcnew Query(); //<-- Form 2 for input.
F->ShowDialog();
System::String^ StringF = F->textBox1->Text; //<-- Set StringF as Value from text box!!!
MessageBox::Show(StringF); //<---- Tells me the string has values :)
}
public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::String^ AddStr = "FFox - " + StringF;
IntPtr ptr2 = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(AddStr);
HWND FFox = FindWindow(0, (LPCSTR)ptr2.ToPointer());
if(FFox == NULL)
{
MessageBox::Show("Cant Find FF :(");
MessageBox::Show(StringF); //<--- Tells me the string is blank!! WHY?!?!
}