鼠标拖动无边框窗口

1、  

        Point downpoint = new Point();
        //事件,鼠标按下,获取当前坐标
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            downpoint.X = -e.X;
            downpoint.Y = -e.Y;
        }

        //事件,鼠标移动,赋值新坐标
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Point mouseSet = Control.MousePosition;
                mouseSet.Offset(downpoint.X, downpoint.Y);
                Location = mouseSet;
            }
        }

 

2、

        int x;
        int y;
        //事件,鼠标按下,获取当前坐标
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            x = e.X;
            y = e.Y;
        }
        //事件,鼠标移动,赋值新坐标
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                this.Left += e.X - x;
                this.Top += e.Y - y;
            }
        }

 

Winform中播放声音

1、添加命名空间

         using System.Media;

2、编写代码

         string sound = Application.StartupPath + "/sound/msg.wav";     //音频文件放在exe文件所在目录下的sound文件夹下。Application.StartupPath:程序exe所在的位置。
         SoundPlayer player = new SoundPlayer(sound);
         player.Load();    //把声音加载到内存
         //player.PlayLooping();    //循环播放
         player.Play();    //播放声音

 

启动外部EXE程序

         System.Diagnostics.Process.Start(@"D:\Program Files(x86)\Tencent\QQ\QQProtect\Bin\QQProtect.exe");

 

posted on 2014-11-07 02:49  幻影K  阅读(354)  评论(0编辑  收藏  举报