摘要: 首先把主窗体中的控件改为public,// Form1中新建窗体语句Form2 f2 = new Form2(this); // Form2中获得Form1对象Form1 f1;public Form2(Form1 f){ InitializeComponent(); f1 = f;}// Form2中改Form1属性语句f1.label1.Text = "Hello, Form1!"; 阅读全文
posted @ 2011-04-23 23:28 清风行云 阅读(390) 评论(3) 推荐(0) 编辑
摘要: const int WM_SYSCOMMAND = 0x112; const int SC_CLOSE = 0xF060; const int SC_MINIMIZE = 0xF020; const int SC_MAXIMIZE = 0xF030; protected override void WndProc(ref Message m) { if (m.Msg == WM_SYSCOMMAND) { if (m.WParam.ToInt32() == SC_MINIMIZE) { this.Visible = false; return; } } base.WndProc(ref m); 阅读全文
posted @ 2011-04-23 22:39 清风行云 阅读(378) 评论(0) 推荐(0) 编辑
摘要: DialogResult a = MessageBox.Show("内容", "标题", MessageBoxButtons.YesNo, MessageBoxIcon.Question);if (a == DialogResult.Yes) // Yes的操作else // No的操作 阅读全文
posted @ 2011-04-23 12:15 清风行云 阅读(249) 评论(0) 推荐(0) 编辑
摘要: Form box = new Form();box.FormBorderStyle = 0;box.TopMost = true;box.BackgroundImage = photo;box.Location = new Point(?, ?);box.StartPosition = FormStartPosition.Manual; // 重要!box.Size = new Size(?, ?);box.Show(); 阅读全文
posted @ 2011-04-23 12:09 清风行云 阅读(188) 评论(0) 推荐(0) 编辑
摘要: System.Windows.Forms.Screen screen = Screen.PrimaryScreen;System.Drawing.Rectangle rct = screen.Bounds;// rct.Height; rct.Width; 即是屏幕的高和宽 阅读全文
posted @ 2011-04-23 12:06 清风行云 阅读(327) 评论(0) 推荐(0) 编辑
摘要: qipan[i, j].MouseMove += new MouseEventHandler(qipan_MouseMove);// 打完 += 后按两下 TAB 会自动补齐事件名和事件函数体 void qipan_MouseMove(object sender, MouseEventArgs e){ MyPictureBox p = (MyPictureBox)sender; // 然后可以通过p来对图片控件进行一些操作 // 还可以通过 e.X 来获取鼠标坐标} 阅读全文
posted @ 2011-04-23 12:03 清风行云 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 以图片控件为例:PictureBox[,] qipan = new PictureBox[10, 10]; // 绘制10*10的棋盘qipan[i, j] = new PictureBox();qipan[i, j].Parent = this; // importantqipan[i, j].Size = new Size(10, 10);qipan[i, j].Location = new Point(j*10, i*10);qipan[i, j].BackColor = Color.Transparent;// 注:PictureBox可以继承,增加自己的一些成员变量。 阅读全文
posted @ 2011-04-23 11:59 清风行云 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 资源需要嵌入.resx中using System.Reflection;using System.Resources; Assembly currentAssembly = Assembly.GetExecutingAssembly(); // 读取资源文件string resourceRootName = "工程名.Properties.Resources";ResourceManager resourcemanager = new ResourceManager(resourceRootName, currentAssembly);// 使用图片资源Bitmap 资源变 阅读全文
posted @ 2011-04-23 11:54 清风行云 阅读(477) 评论(0) 推荐(0) 编辑