Drag the mouse without a border window
1.
Mouse drag
Point downpoint = new Point ();
event, mouse down, get current coordinates
private void Panel1_mousedown (object sender, MouseEventArgs e)
{
Downpoint. X =-e.x;
Downpoint. Y =-e.y;
}
event, mouse move, assignment new coordinates
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;
event, mouse down, get current coordinates
private void Form1_mousedown (object sender, MouseEventArgs e)
{
x = e.x;
y = e.y;
}
event, mouse move, assignment new coordinates
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;
}
}
Play sound in WinForm
1. Add a Namespace
Using System.Media;
2. Write code
String sound = Application.startuppath + "/sound/msg.wav"; The audio file is placed under the sound folder in the same directory as the EXE file. Application.startuppath: The location where the program EXE is located.
SoundPlayer player = new SoundPlayer (sound);
Player. Load (); Load the sound into memory
Player. Playlooping (); Loop playback
Player. Play (); Play sound
Start an external EXE program
System.Diagnostics.Process.Start (@ "D:\Program Files (x86) \tencent\qq\qqprotect\bin\qqprotect.exe");
141107 WinForm Drag the Borderless window, play audio, start the external EXE program