------------恢复内容开始------------
#region 移动窗口 [DllImport("user32.DLL", EntryPoint = "ReleaseCapture")] private extern static void ReleaseCapture(); [DllImport("user32.DLL", EntryPoint = "SendMessage")] private extern static void SendMessage(System.IntPtr hWnd, int wMsg, int wParam, int lParam);
//Panel控件,鼠标点击时移动窗口位置 private void PanelTitle_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(this.Handle, 0x112, 0xf012, 0); } #endregion
#region 托盘双击事件,显示出窗体 private void notifyIcon1_DoubleClick(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Show(); this.WindowState = FormWindowState.Normal; this.notifyIcon1.Visible = true; this.ShowInTaskbar = true; } } #endregion
#region 退出窗体事件 private void BtnClose_Click(object sender, EventArgs e) { if (MessageBox.Show("确定是否退出软件?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { this.Dispose(); System.Environment.Exit(System.Environment.ExitCode); } } #endregion
#region 窗体最小化事件 private void BtnMin_Click(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Normal) { this.Hide(); this.ShowInTaskbar = true; this.notifyIcon1.Visible = true; this.WindowState = FormWindowState.Minimized; } } #endregion
#region BtnOpenFile按钮事件 private void BtnOpenFile_Click(object sender, EventArgs e) { if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK) { TxtfoldPath.Text = this.folderBrowserDialog1.SelectedPath; } }
//鼠标悬停时提示文字信息 private void BtnOpenFile_MouseEnter(object sender, EventArgs e) { ToolTip p = new ToolTip(); p.ShowAlways = true; //是否在鼠标悬浮时提示消息 p.SetToolTip(this.BtnOpenFile, "请选择存放目录"); } #endregion
------------恢复内容结束------------