• 窗体中拖动panel,并且不会拖动至窗体外部程序实现方法。


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;

    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            Point pt;
            MouseEventHandler hand;
            public Form1()
            {
                InitializeComponent();        
            }

            private void panel1_MouseDown(object sender, MouseEventArgs e)
            {
                pt = Cursor.Position;
            }

            private void panel1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    this.Cursor = new Cursor(Cursor.Current.Handle);
                    Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y);
                    Cursor.Clip = new Rectangle(new Point(this.Location.X,  this.Location .Y + 30), new Size(this.Width, this.Height - 30));
                    int px = Cursor.Position.X - pt.X;
                    int py = Cursor.Position.Y - pt.Y;
                    panel1.Location = new Point(panel1.Location.X + px, panel1.Location.Y + py);
                    pt = Cursor.Position;               
                }
            }     

            private void Form1_Load(object sender, EventArgs e)
            {
                hand = new MouseEventHandler(panel1_MouseMove);
                panel1.MouseMove += hand;
                   this.Cursor = Cursors.Default;
            }   

            private void panel1_MouseUp(object sender, MouseEventArgs e)
            {
                Cursor.Clip = new Rectangle(new Point(0, 0), new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height));
                System.Diagnostics.Process[] ss = System.Diagnostics.Process.GetProcesses();

                foreach (System.Diagnostics.Process s in ss)
                {
                    if (s.ProcessName.ToLower() == "test")
                    {
                        s.Kill();      
                    }          
                }
            }      
        
        }
    }

  • 相关阅读:
    keep-alive的深入理解与使用(配合router-view缓存整个路由页面)
    vue无法自动打开浏览器
    解决vue页面刷新或者后退参数丢失的问题
    vue 跳转并传参,实现数据实时更新
    Struts2 有关于无法正常的使用通配符
    有关于java反编译工具的使用
    Action名称的搜索顺序
    Struts2 的 值栈和ActionContext
    在Action 中访问web资源
    oracle 创建database Link
  • 原文地址:https://www.cnblogs.com/gaolijun1986/p/2114066.html
Copyright © 2020-2023  润新知