`
guowee
  • 浏览: 174375 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

如何在windows mobile 中用编程的方法弹出旋转的等待小图标

阅读更多

最近在研究Windows mobile的时候,想自己做一个弹出类似程序启动时候的小图标,于是查了一下Windows mobile 5的SDK手册。

 

发现Shows how to establish the shape of a wait cursor. 这个例子。于是详看了一下。

 

A cursor is a small bit image that reflects the position of a pointing device.

Because standard cursors are predefined, it is unnecessary to create them. To use a standard cursor, an application retrieves a cursor handle by calling the LoadCursor function. A cursor handle is a unique value of the HCURSOR type that identifies a standard or custom cursor.

The following code example shows the syntax for the LoadCursor function.

HCURSOR LoadCursor( 
   HINSTANCE hInstance, // Handle to the application instance
   LPCTSTR lpCursorName // Name string or cursor resource identifier
);

Here, hInstance is a handle to an instance of the module whose executable file contains the cursor to be loaded, and lpCursorName is a pointer to the name of the cursor to be loaded. It can also point to a resource identifier. To use a predefined cursor, the application must set hInstance to NULL and lpCursorName to one of the predefined cursor values.

Windows CE–based platforms implement cursors in different ways depending on the platform configuration. For example, on many Windows CE–based platforms, users interact with applications by tapping the stylus on the screen; because there is no mouse, there is no need for a cursor to indicate the current mouse position. Target platforms not requiring mouse support typically implement Iconcurs.dll. This component enables you to specify only the wait cursor when calling the LoadCursor function. Applications should display the wait cursor when executing a command that renders the current window or the system unresponsive to user input. To establish the shape of a wait cursor, you must call the SetCursor function in conjunction with the LoadCursor function. The following code example shows how to establish the shape of a wait cursor.

SetCursor(LoadCursor(NULL, IDC_WAIT));

Target platforms that support mouse cursors typically include Mcursor.dll. This component implements cursors similar to Windows-based desktop platforms; all standard cursors, except color cursors, are available when calling the LoadCursor function. Windows CE also supports custom cursors.

To create a custom cursor

  1. Draw the cursor by using a graphics application.
  2. Include the cursor as a resource in the application resource-definition file.

    Using a cursor resource avoids device dependence, simplifies localization, and enables applications to share cursor designs.

  3. Call LoadCursor at run time to retrieve the cursor handle.

    Cursor resources contain data for several different display devices. The LoadCursor function automatically selects the most appropriate data for the current display device. To load a cursor directly from a .cur or .ani file, use the LoadCursorFromFile function instead of the LoadCursor function.

Once you create and load a cursor, you can hide and redisplay the cursor, without changing the cursor design, by using the ShowCursor function. This function uses an internal counter to determine when to hide or display the cursor. An attempt to show the cursor increments the counter; an attempt to hide the cursor decrements the counter. The cursor is visible only if this counter is greater than or equal to zero.

Additionally, you can change the design of the cursor by using the SetCursor function and specifying a different cursor handle.

 

原来实现起来如此之方便啊!

在C++中只要把如下两个方法结合起来使用,就可以了。

SetCursor(LoadCursor(NULL, IDC_WAIT));

SetCursor(LoadCursor(NULL, IDC_NO));

 

在C#中

 

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                Cursor.Show();

                btnLogin.Enabled = false;
            }           
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "错误");
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                btnLogin.Enabled = true;
           

            }

 

本文参考了如下文章:

http://topic.csdn.net/u/20080321/13/b73582cd-d9ca-4a04-9d3f-d7e36e7ff869.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics