在.Net1.1中默认情况下是不支持动画光标的,此是若要使WinForm的光标变为动画光标,就应使用WinAPI了:
函数功能:该函数根据一个文件中所含的数据创建光标。该文件由它的名字所指定或由一个系统光标鉴别器指定,该函数返回一个新建光标的句柄,文件所包含的光标数据可以是光标格式(CUR)或运动光标格式(.ANI)。
函数原型:HCURSOR LoadCursorFromFile(LPCTSTR IpFileName);
参数:
IpFileName:指明创建光标所用的文件数据资源,文件中的数据格式必须是COR或ANI,如果IpFileName的高位字为非零,则IpFileName就是指向一个字符串的指针,该字符串是包含光标数据的文件的名字。
1
public
class
BDCursor
2![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
3
[DllImport("USER32.Dll")]
4
private static extern IntPtr LoadCursorFromFile( string IpFileName ); public static Cursor GetBDCursor( String fileName, IntPtr cursorPtr )
5![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
6
Cursor resultCursor = new Cursor( cursorPtr );
7
IntPtr customCursor = LoadCursorFromFile( fileName );
8![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
resultCursor.GetType().InvokeMember("handle",BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.SetField,null,resultCursor,new object[]
{ customCursor });
9
return resultCursor;
10
}
11
}
![None.gif](/Images/OutliningIndicators/None.gif)
2
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](/Images/dot.gif)
3
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
4
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
5
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](/Images/dot.gif)
6
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
7
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
8
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](/Images/dot.gif)
9
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
10
![ExpandedSubBlockEnd.gif](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
11
![ExpandedBlockEnd.gif](/Images/OutliningIndicators/ExpandedBlockEnd.gif)