查看完整版本: C++如何把ani的动态光标添加到资源里去呢?

netice 2008-4-18 22:08

C++如何把ani的动态光标添加到资源里去呢?

C++如何把ani的动态光标添加到资源里去呢?
添加cur静态的都可以。。。动态的不怎么会弄

找了下

[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][color=#000000]Screen[/color][color=#000000]->[/color][color=#000000]Cursors[[/color][color=#000000]1[/color][color=#000000]][/color][color=#000000]=[/color][color=#000000]LoadCursor(C1);
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][/color][color=#008000]//[/color][color=#008000]Screen->Cursors[1]=LoadCursor(C2);
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][/color][color=#008000]//[/color][color=#008000]如果想载入动态光标,会失败
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img]
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][/color][color=#008000]//[/color][color=#008000]加载动态光标[/color][color=#008000]
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][/color][color=#000000]TResourceStream [/color][color=#000000]*[/color][color=#000000] rs[/color][color=#000000]=[/color][color=#0000ff]new[/color][color=#000000] TResourceStream(([/color][color=#0000ff]int[/color][color=#000000])HInstance,[/color][color=#000000]"[/color][color=#000000]C2[/color][color=#000000]"[/color][color=#000000],[/color][color=#000000]"[/color][color=#000000]file);[/color][color=#000000]
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][/color][color=#008000]//[/color][color=#008000]生成临时的光标文件[/color][color=#008000]
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][/color][color=#0000ff]char[/color][color=#000000] temp_path[MAX_PATH];
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img]GetTempPath(MAX_PATH,temp_path);
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img]strcat(temp_path,[/color][color=#000000]"[/color][color=#000000]temp.ani[/color][color=#000000]"[/color][color=#000000]);
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img]rs->SaveToFile(temp_path);
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img]
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img]Screen[/color][color=#000000]->[/color][color=#000000]Cursors[[/color][color=#000000]2[/color][color=#000000]][/color][color=#000000]=[/color][color=#000000]LoadCursorFromFile(temp_path);
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img][/color][color=#0000ff]this[/color][color=#000000]->[/color][color=#000000]Cursor[/color][color=#000000]=[/color][color=#000000]TCursor([/color][color=#000000]2[/color][color=#000000]);
[img]http://www.cppblog.com/Images/OutliningIndicators/None.gif[/img]delete rs;[/color]






[color=#000000]以上没怎么看明白[/color]

netice 2008-4-19 02:59

研究出来了,,用这2个函数可以实现

HCURSOR            attackCursor;
attackCursor=LoadCursorFromFile(".\\element\\cursors\\attack.ani");
SetCursor(attackCursor);


但是有个问题,,为什么要不停的进行SetCursor( )啊,,汗,,,不能一次性设置吗?
郁闷,这样不停在主循环里设置有时候容易恢复到窗口句柄里设置的光标模式。。。。汗。。
是不是我的方法不对啊??
华哥在不在???帮忙解答下。。。555555555555555
页: [1]
查看完整版本: C++如何把ani的动态光标添加到资源里去呢?