当我单击GUI上的按钮时,我想唤起一种读取图像(使用OpenCV)的方法。
据我所知,混合托管代码和非托管代码存在问题:button_clicked事件是ref类的一部分,而我的类(clHistogram)是一个类。
FormWorkbench.h:
namespace Workbench{
public ref class FormWorkbench : public System::Windows::Forms::Form
{
*automatically generated code*
}
public: bool getButton1WasClicked() { return button1WasClicked;}
private: bool button1WasClicked;
private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
button1WasClicked = true;
}
}
这就是我要调用的函数:
void main(array <String^>^ args) {
clHistogram objHist;
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Workbench::FormWorkbench form;
Application::Run(%form);
if (Workbench::FormWorkbench::getButton1WasClicked) {
objHist.readImage("C:/Users/lausi/Desktop/original.png");
}
}
感谢您的帮助
Niko