1

C# で WPF アプリケーションを開発していますが、すべてのマウス カーソルの種類をテストする方法があるかどうかを知りたいです。カーソルの種類を変更するには、次のようにします。

Mouse.OverrideCursor = Cursors.Cross;

以下のようなタイマーを作成しました。

 DispatcherTimer dt = new DispatcherTimer();
 dt.Interval = new TimeSpan(0, 0, 0, 0, 300);
 dt.Tick += new EventHandler(dt_Tick);
 dt.Start();

これが私の問題です:

Cursor c = Cursors.AppStarting;
void dt_Tick(object sender, EventArgs e)
{
   Mouse.OverrideCursor = c++; //this doesn't work. 
} 

これどうやってするの?

4

1 に答える 1

3

次のことを試してください。

int current = 0;
PropertyInfo[] cursors;
void dt_Tick(object sender, EventArgs e) {
    if(cursors == null)
        cursors = typeof(Cursors).GetProperties();
    Mouse.OverrideCursor = 
        (Cursor)cursors[(current++) % cursors.Length].GetValue(null, 
                                                               new object[] { });
}
于 2012-07-23T14:05:27.833 に答える