form2.cs

来自「用C#实现了计事本的功能 对初学者相当有用的」· CS 代码 · 共 80 行

CS
80
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace jishiben
{
    public partial class Form2 : Form
    {
        private int num_old_x_length = 0;
        private int num_old_y_length = 0;
        private int num_new_x_length = 0;
        private int num_new_y_length = 0;
        public Form2()
        {
            InitializeComponent();
        }
        [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
        public static extern bool FlashWindow(IntPtr handle, bool bInvert);

        private void Form2_Load(object sender, EventArgs e)
        {
            FlashWindow(this.Handle, true);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                VisitLink();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to open link that was clicked.");
            }
            this.Close();
   
        }
        private void VisitLink()
        {
            // Change the color of the link text by setting LinkVisited 
            // to true.
            linkLabel1.LinkVisited = true;
            //Call the Process.Start method to open the default browser 
            //with a URL:
            System.Diagnostics.Process.Start("http://www.baidu.com");
        }

        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            this.Close();
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Middle)
            {
 
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (sender == timer1)
            {
                num_new_x_length = Control.MousePosition.X - this.Location.X;
                num_new_y_length = Control.MousePosition.Y - this.Location.Y;

                this.Location = new Point(this.Location.X + num_new_x_length - num_old_x_length, this.Location.Y + num_new_y_length - num_old_y_length);

            }
        }

        
       
    }
}

⌨️ 快捷键说明

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