frmMove.cs文件如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace clientLearning.Rubish
{
public partial class frmMove : Form
{
public frmMove()
{
InitializeComponent();
}
internal static int WM_NCHITTEST = 0x84; //移动鼠标,按住或释放鼠标时发生的系统消息
internal static IntPtr HTCLIENT = (IntPtr)0x1;//工作区
internal static IntPtr HTCAPTION = (IntPtr)0x2; //标题栏
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCHITTEST)
{
base.WndProc(ref m);
if (m.Result == HTCLIENT)
{
m.Result = HTCAPTION;//模拟标题栏,移动或双击可以最大或最小化窗体
}
}
else
{
base.WndProc(ref m);
private void button_min_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics g = e.Graphics;
SolidBrush myBrush = new SolidBrush(Color.Blue);
Font myFont1 = new Font("Times New Roman", 30);
Font myFont2 = new Font("Times New Roman", 10);
SolidBrush c_myBrush = new SolidBrush(Color.Black);
g.DrawString("*", myFont2, myBrush, 0, 0);
}
private void button_close_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics g = e.Graphics;
SolidBrush myBrush = new SolidBrush(Color.Blue);
Font myFont1 = new Font("Times New Roman", 30);
Font myFont2 = new Font("Times New Roman", 10);
SolidBrush c_myBrush = new SolidBrush(Color.Black);
g.DrawString("X", myFont2, myBrush, 0, 0);