111,129
社区成员
发帖
与我相关
我的任务
分享private Point ptMouseCurrrnetPos, ptMouseNewPos,
ptFormPos, ptFormNewPos;
private bool blnMouseDown = false;
private ExcelTreatment.ExcelSelect pParent;
private void frmTopMost_Load(object sender, EventArgs e)
{
this.Show();
this.Top = 100;
this.Left = Screen.PrimaryScreen.Bounds.Width - 100;
this.Width = 60;
this.Height = 60;
}
private void frmTopMost_MouseMove(object sender, MouseEventArgs e)
{
if (blnMouseDown)
{
//Get the current position of the mouse in the screen
ptMouseNewPos = Control.MousePosition;
//Set window position
ptFormNewPos.X = ptMouseNewPos.X - ptMouseCurrrnetPos.X + ptFormPos.X;
ptFormNewPos.Y = ptMouseNewPos.Y - ptMouseCurrrnetPos.Y + ptFormPos.Y;
//Save window position
Location = ptFormNewPos;
ptFormPos = ptFormNewPos;
//Save mouse position
ptMouseCurrrnetPos = ptMouseNewPos;
}
}
private void frmTopMost_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
blnMouseDown = true;
// Save window position and mouse position
ptMouseCurrrnetPos = Control.MousePosition;
ptFormPos = Location;
}
}
private void frmTopMost_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
//Return back signal
blnMouseDown = false;
}
private void frmTopMost_DoubleClick(object sender, EventArgs e)
{
SwitchToMain();
}
private System.Windows.Forms.ContextMenu mnuPopup;
private System.Windows.Forms.MenuItem mnuMainWindow;
private System.Windows.Forms.MenuItem mnuExit;
private void mnuMainWindow_Click(object sender, System.EventArgs e)
{
SwitchToMain();
}
private void mnuExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}