这是关系到: 前一个问题
但问题是我的代码只有当我真的快上方和周围TableLayoutPanel中真正移动鼠标失败。
是有可能,C#或窗户报告/触发事件失灵由于快速移动鼠标?
如果是这样,我怎么纠正?
谢谢。 我希望这不被认为是双张贴。 如果是这样,道歉。
这是关系到: 前一个问题
但问题是我的代码只有当我真的快上方和周围TableLayoutPanel中真正移动鼠标失败。
是有可能,C#或窗户报告/触发事件失灵由于快速移动鼠标?
如果是这样,我怎么纠正?
谢谢。 我希望这不被认为是双张贴。 如果是这样,道歉。
鼠标不通过它传递的每个像素报告其位置,有报道之间的时间间隔为20ms。 如果你管理这个区间内交叉你的控制,它会抓住任何鼠标事件都没有。
我解决了这个问题。 这是重新排序的逻辑流程的一个问题。
溶液跨越3个鼠标事件的MouseEnter,的MouseMove,鼠标离开。
private PictureBox HomeLastPicBox = null;
private TableLayoutPanelCellPosition HomeLastPosition = new TableLayoutPanelCellPosition(0, 0);
private void HomeTableLayoutPanel_MouseMove(object sender, MouseEventArgs e)
{
PictureBox HomeCurrentPicBox = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(e.Location));
if ((HomeCurrentPicBox != HomeLastPicBox) && (HomeCurrentPicBox != null))
{
HomeLastPicBox = (PictureBox)HomeTableLayoutPanel.GetControlFromPosition(HomeLastPosition.Column, HomeLastPosition.Row);
if (GameModel.HomeCellStatus(HomeLastPosition.Column, HomeLastPosition.Row) == Cell.cellState.WATER)
{
HomeLastPicBox.Image = Properties.Resources.water;
}
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
if (GameModel.HomeCellStatus(HomeCurrentPosition.Column, HomeCurrentPosition.Row) == Cell.cellState.WATER)
{
HomeCurrentPicBox.Image = Properties.Resources.scan;
HomeLastPosition = HomeCurrentPosition;
}
gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox).Column) + "," + HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox).Row);
}
}
private void HomeTableLayoutPanel_MouseEnter(object sender, EventArgs e)
{
Point p = HomeTableLayoutPanel.PointToClient(Control.MousePosition);
PictureBox HomeCurrentPicBox = (PictureBox)(HomeTableLayoutPanel.GetChildAtPoint(p));
if (HomeCurrentPicBox != null)
{
TableLayoutPanelCellPosition HomeCurrentPosition = HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox);
if (GameModel.HomeCellStatus(HomeCurrentPosition.Column, HomeCurrentPosition.Row) == Cell.cellState.WATER)
{
HomeCurrentPicBox.Image = Properties.Resources.scan;
}
gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox).Column) + "," + HomeTableLayoutPanel.GetCellPosition(HomeCurrentPicBox).Row);
}
}
private void HomeTableLayoutPanel_MouseLeave(object sender, EventArgs e)
{
if (GameModel.HomeCellStatus(HomeLastPosition.Column, HomeLastPosition.Row) == Cell.cellState.WATER)
{
HomeLastPicBox = (PictureBox)HomeTableLayoutPanel.GetControlFromPosition(HomeLastPosition.Column, HomeLastPosition.Row);
HomeLastPicBox.Image = Properties.Resources.water;
gameFormToolTip.SetToolTip(HomeTableLayoutPanel, GameModel.alphaCoords(HomeTableLayoutPanel.GetCellPosition(HomeLastPicBox).Column) + "," + HomeTableLayoutPanel.GetCellPosition(HomeLastPicBox).Row);
}
}
我想我会张贴未来求知者的解决方案。
谢谢。