是否可以让功能等到按下特定按钮?
例如,我有一个名为foo()
的函数,我希望它的行为如下:
void foo(int a, int b)
{
int result = a*b;
if(some_button got pressed)
MessageBox::Show(result.ToString());
}
请注意,我不希望按钮内有这样的代码:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
foo1(num1,num2);
}
void f1(int a, int b)
{
int result = a*b;
MessageBox::Show(result.ToString());
}