我的新表单中有这个构造函数:
public MagnifierForm(Point MousePosition)
{
_doMove = true;
FormBorderStyle = FormBorderStyle.None;
ShowInTaskbar = false;
TopMost = true;
Width = 150;
Height = 150;
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(ClientRectangle);
Region = new Region(gp);
mTimer = new Timer();
mTimer.Enabled = true;
mTimer.Interval = 20;
mTimer.Tick += new EventHandler(HandleTimer);
mScreenImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
//maybe subtract half of the forms width/height from the points (offset them)
mStartPoint = MousePosition;
mTargetPoint = MousePosition;
speed = 0.35F;
}
在构造函数的底部,我添加了以下代码:
mStartPoint = MousePosition;
mTargetPoint = MousePosition;
在 Form1 我有这个代码:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.M))
{
if (mf == null)
{
mf = new Magnifier20070401.MagnifierForm(System.Windows.Forms.Cursor.Position);
mf.StartPosition = FormStartPosition.Manual;
mf.Location = Control.MousePosition;
mf.Show();
this.Select();
}
else if (mf.IsDisposed)
{
mf = new Magnifier20070401.MagnifierForm(System.Windows.Forms.Cursor.Position);
mf.StartPosition = FormStartPosition.Manual;
mf.Location = Control.MousePosition;
mf.Show();
}
else
{
mf.Close();
mf = null;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
一切正常。这个 mStartPoint 设置表单的位置/位置也很好用。
但是这句话是什么意思?//也许从点中减去一半的表格宽度/高度(偏移它们)
句子与以下内容有关:mStartPoint 和 mTargetPoint
如果我想使用这句话,有人可以给我看一个例子吗?