141107●Winform拖动无边框窗口、播放音频、启动外部exe程序
2020-12-13 16:09
标签:winform io ar os sp for 文件 on art 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; } } 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(); //播放声音 System.Diagnostics.Process.Start(@"D:\Program Files(x86)\Tencent\QQ\QQProtect\Bin\QQProtect.exe"); 141107●Winform拖动无边框窗口、播放音频、启动外部exe程序 标签:winform io ar os sp for 文件 on art 原文地址:http://www.cnblogs.com/phantom-k/p/4080339.html鼠标拖动无边框窗口
Winform中播放声音
启动外部EXE程序
上一篇:C# partial 关键字
文章标题:141107●Winform拖动无边框窗口、播放音频、启动外部exe程序
文章链接:http://soscw.com/essay/35811.html