I wonder if it is possible to call the function void OneFunction()
inside the buttoncontrol.

namespace Test1 
{
   public ref class Form1 : public System::Windows::Forms::Form
   {


private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
 {
     // Is it possible to Execute/Call OneFunction() here ?
 }


   };
}

void OneFunction()
{
   //Do some stuff
}

>>I wonder if it is possible to call the function void OneFunction()

Don't know myself. Instead of asking us if it is possible, why don't you just try to do it yourself? If you did, what were the results?

I am not sure myself what I am doing really. I dont know if it is possible to put a void outside the Form Class.
However the code compiles. The thing is that the void OneFunction is outside namespace and Form Class, so I cant ex set a MessageBox:: Show("Code executed");
or create a file with ofstream to confirm.
So I tried to put a loop only like this but don´t know if it is executing when pressing the button.
Sometimes the Form or button get "stuck" for a few seconds so you cant press the button when you are executing a loop like below but this doesn´t seem to happen either.
I am only trying to see if this was possible for other solutions I have in mind.

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) 
{
 OneFunction;
} 

}; 
} 


void OneFunction()
{
   for( int i = 0; i < 20000000000; i++) 
  { 
     int is = 0;
  }
}

>>I wonder if it is possible to call the function void OneFunction()

Don't know myself. Instead of asking us if it is possible, why don't you just try to do it yourself? If you did, what were the results?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.