如题:
下面实现时出现异常是怎么回事?
public partial class Window1 : System.Windows.Window
{
private Timer _time = new Timer(2000);
public Window1()
{
InitializeComponent();
_time.Elapsed += new ElapsedEventHandler(OnTimedEvent);
_time.Enabled = true;
_time.Start();
this.WindowState = WindowState.Maximized;
}
private void OnTimedEvent(object source, ElapsedEventArgs e)
{
_time.Close();
try
{
this.Cursor = Cursors.None;
}
catch ( Exception error )
{
MessageBox.Show(error.Message.ToString());
}
}
private void OnMouseMove(Object sender,MouseEventArgs e)
{
_time.Enabled = true;
_time.Start();
this.Cursor = Cursors.Arrow;
}
}
------解决方案--------------------------------------------------------
Cursors没有None,应该编不过吧。要用API去destroy光标。但什么时候恢复光标也是个问题,可能要hook系统mouse的消息才行。