Windows mobile 的滑鼠狀態控制

來源:互聯網
上載者:User

很多人都會遇到一個問題,當我們執行一個複雜的操作是,介面會卡住。使用者體驗會感覺不好。那如果可以添加一個滑鼠的忙碌狀態的話就會好很多了。

以下是很簡單的代碼,用於控制滑鼠的狀態。

  1    public static class Cursor

 2     {
 3         [DllImport("coredll.dll")]
 4         public static extern IntPtr LoadCursor(IntPtr hInstance, CursorType lpCursorName);
 5         [DllImport("coredll.dll")]
 6         public static extern IntPtr SetCursor(IntPtr pCursor);
 7 
 8         public delegate void doing();
 9 
10         public enum CursorType : uint
11         {
12             IDC_ARROW = 32512U,            
13             IDC_WAIT = 32514U           
14         } 
15 
16         public static void Wait(){
17             SetCursor(LoadCursor(IntPtr.Zero, CursorType.IDC_WAIT));
18         }
19 
20         public static void Default()
21         {
22             SetCursor(LoadCursor(IntPtr.Zero, CursorType.IDC_ARROW));
23         }
24 
25         public static void DoSomething(doing something)
26         {
27             Wait();
28             something();
29             Default();
30         }
31 
32     }

其實方法很簡單,在複雜耗時的操作之前調用Cursor.Wait()方法,在方法執行完之後再調用Cursor.Default()。而每次都要進行這兩次操作會比較麻煩,所以我加入了DoSomething方法,用委託去實現,則可以直接調用Curosr. DoSomething(委託)去實現。當然委託還可以自己拓展,用於滿足自己程式的需要。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.