最近客户提出个很BT的要求:在Load Data时,要求Cursor为沙漏形状,而且当Mouse 移动到Form的Title时也一样.我试了API的SetCursor,好像没作用?

解决方案 »

  1.   

    这个要求很BT吗?这个是最基本的处理 button2_Click
    {
    try
    {
    Cursor = Cursors.WaitCursor;
                      
                      //数据处理....
    }
    finally
    {
    Cursor = Cursors.Default;
    }
    }
      

  2.   

    :D你说的我当然知道,但这个只是在Form的工作区域生效,客户要求的是在Form的标题栏,还有鼠标移出了此Form也要是沙漏
      

  3.   

    ??
    设定Cursors.WaitCursor后,如果Load Data过程不是多线程或异步调用,应用程序是处于等待状态,Mouse应该一直是WaitCursor的啊
      

  4.   

    当Mouse 移动到Form的Title时也一样
    -----------------
    我想问一下这样起什么作用先?
    可以把Form的Title禁用嘛!
      

  5.   

    sskset(断点)的代码是正确的。而且,就像楼主说要求的,移动到form的title时候,也是沙漏状的
    除非你把它移动到下面的任务栏才会变。
    但如果要求移动到任务栏也还是沙漏的话,那确实很BT了,也不符合用户习惯阿。
    就像你的程序加入死掉了,我把鼠标移到任务管理器上还是等待状态,那岂不是很别扭?
      

  6.   

    使用Cursor.current设置整个应用程序的光标。
      

  7.   

    {
    try
    {
    Cursor = Cursors.WaitCursor;
                      
                      //数据处理....
    }
    finally
    {
    Cursor = Cursors.Default;
    }
    }
      

  8.   

    Public Overridable Property Cursor As Cursor将 Cursor 分配给控件的 Cursor 属性,以便更改在鼠标指针位于该控件上时显示的光标。要临时更改应用程序上所有控件的鼠标光标,请设置 Cursor.Current 属性。在填充 ComboBox 或者在保存或加载文件时,通常应将 Cursor.Current 属性设置为等待光标。
      

  9.   

    using System;
    using System.Runtime.InteropServices;namespace WindowsApplication2
    {
    /// <summary>
    /// Summary description for clsSetCursor.
    /// </summary>
    public class clsSetCursor
    {
    #region Const const int OCR_WAIT = 32514;
    const int OCR_NORMAL = 32512 ;
    const int OCR_APPSTARTING =32650; #endregion #region API
    [DllImport("user32.dll")] public static extern IntPtr LoadCursorFromFile( string fileName );
    [DllImport("user32")] public static extern int SetSystemCursor(IntPtr hcur, int id)  ;
    [DllImport("user32.dll")] static extern IntPtr LoadCursor(int hInstance, int lpCunrsorName); 
      #endregion public clsSetCursor()
    {
    //
    // TODO: Add constructor logic here
    //
    // Private Const OCR_NORMAL = 32512
    // Private Const IDC_SIZEALL = 32646&
    // Private Declare Function SetSystemCursor Lib "user32" (ByVal hcur As Long, ByVal id As Long) As Long
    // Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
    // Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
    // Private Sub Form_Load()
    // 'KPD-Team 2001
    // 'URL: http://www.allapi.net/
    // 'E-Mail: [email protected]
    // Dim hCursor As Long
    // 'load the 'Size-All' cursos
    // hCursor = LoadCursor(ByVal 0&, IDC_SIZEALL)
    // 'replaces the contents of the system cursor specified by OCR_NORMAL with the contents of the 'size-all' cursor
    // SetSystemCursor hCursor, OCR_NORMAL
    // 'clean up
    // DestroyCursor hCursor
    // End Sub
    } public static void setToAppStarting()
    {
    IntPtr iP=LoadCursorFromFile(@"C:\Documents and Settings\Felix Lau\Desktop\appstart.ani");
    // int i=0;
    IntPtr ii=LoadCursor(0,OCR_APPSTARTING);
    SetSystemCursor(iP,OCR_NORMAL);
    } public static void setToNormal()
    {
    //IntPtr ii=LoadCursor(0,OCR_NORMAL);
    IntPtr iP=LoadCursorFromFile(@"C:\Documents and Settings\Felix Lau\Desktop\fillitup.ani");
    SetSystemCursor(iP,OCR_NORMAL);
    } public static IntPtr getNormal()
    {
    //return LoadCursor(0,OCR_NORMAL);
    return new IntPtr(0);
    }
    }
    }
      

  10.   

    移出窗体外这个要求好像不太好,与window机制不合