⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 event1.cpp

📁 C++ Source code from a tutorial
💻 CPP
字号:
// This is the main project file for VC++ application project 
// generated using an Application Wizard.

#include "stdafx.h"

#using <mscorlib.dll>
#using <System.DLL>
#using <System.Windows.Forms.DLL>

#include <tchar.h>

using namespace System;
using namespace System::Windows::Forms;

// The MyEvents class must be managed with __gc!
__gc class MyEvents {
public:
    void Click(Object* sender, EventArgs* e) {
        Console::WriteLine("Click!");
    }
    void Click2(Object* sender, EventArgs* e) {
        Console::WriteLine("Click2!");
    }
};

// This is the entry point for this application
int _tmain(void)
{
    Form *myform = new Form();
    Button *mybutton = new Button();
    mybutton->Text = "Click!";
    mybutton->Left = 25;
    mybutton->Top = 25;

    // Create the handler object
    MyEvents *events = new MyEvents;

    // Create the delegate
    EventHandler *handler = new EventHandler(
        events, MyEvents::Click);

    // Add the delegate to the multicaster
    mybutton->Click += handler;
    mybutton->Click += new EventHandler(
        events, MyEvents::Click2);

    myform->Controls->Add(mybutton);
    myform->ShowDialog();
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -