📄 26.2.txt
字号:
Listing 26.2 Communication Using Window Messages
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using Microsoft.WindowsCE.Forms;
using System.Runtime.InteropServices;
using System.Text;
namespace _6_MessageWindow
{
public class DeviceWindowsForm : System.Windows.Forms.Form
{
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.Button btnClose;
private MessageHandler handler;
public DeviceWindowsForm()
{
InitializeComponent();
handler = new MessageHandler( this );
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.listBox1 = new System.Windows.Forms.ListBox();
this.btnClose = new System.Windows.Forms.Button();
//
// listBox1
//
this.listBox1.Size = new System.Drawing.Size(240, 226);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(80, 232);
this.btnClose.Text = “Close”;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// DeviceWindowsForm
//
this.Controls.Add(this.btnClose);
this.Controls.Add(this.listBox1);
this.Menu = this.mainMenu1;
this.Text = “Form1”;
}
static void Main()
{
Application.Run(new DeviceWindowsForm());
}
private void btnClose_Click(object sender, System.EventArgs e)
{
}
}
public class MessageHandler : MessageWindow
{
// the main application form
DeviceWindowsForm mainForm;
public MessageHandler(DeviceWindowsForm mainForm)
{
// save the form to post back to
this.mainForm = mainForm;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -