delegate3-C#風windowsアプリ
以前の
を使って、C#に近い形でwindowsアプリを作ってみます。もちろんC++/nativeです。
C#・C++/CLIを使え、とか突っ込まないで下さいw
目標
class Form1 : public Form { private: ButtonPtr button1; //shared_ptr< Button > public: Form1() : button( new Button() ) { InitializeComponents(); } private: void InitializeComponents() { // //button1 // button1->text = "ボタン"; button1->x = ...; button1->y = ...; button1->w = ...; button1->h = ...; button1->click = bind( &Form1::button1_clicked, this, _1, _2 ); //sender, e // //Form1 // this->text = "form1"; this->x = ...; this->y = ...; this->w = ...; this->h = ...; this->closing = bind( &Form1::form1_closing, this, _1, _2 ); //sender, e this->Add( button1 ); } private: void form1_closing( Component* /*sender*/, WindowEvent& /*e*/ ) { system.exit(); } void button1_clicked( Component* /*sender*/, ActionEvent& /*e*/ ) { std::cout << "hoge" << std::endl; } }; int main() { system.Run( FormPtr( new Form1() ) ); //shared_ptr< Form > return 0; }
以上のようなFormクラスを作ってみましょう。