我想在代码执行一个大操作的时候把鼠标指标的形状变为沙漏。
=========================================================================================
最初的源代码如下:hCursor = LoadCursor( NULL, MAKEINTRESOURCE(IDC_WAIT) );
hCursor = SetCursor( hCursor );...
......SetCursor( hCursor ); // 恢复成箭头光标每一个函数调用都成功了,但是鼠标光标的形状却没有改变,我在 MSDN 中翻了一下:If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved. 似乎我如果不把窗口类结构中的光标句柄设为 NULL 的话,每当我移动鼠标,系统就会恢复鼠标的形状。
========================================================================================
然后我就把代码作了如下修改:// Changing cursor shape.
hOldCursor = (HCURSOR) GetClassLong( hwnd, (int) GCL_HCURSOR );
uRet = SetClassLong( hwnd, (int) GCL_HCURSOR, (LONG) NULL );
hCursor = LoadCursor( NULL, MAKEINTRESOURCE(IDC_WAIT) );
hCursor = SetCursor( hCursor );...
......// Resotre curosr shape
SetClassLong( hwnd, GCL_HCURSOR, (LONG) hOldCursor );
SetCursor( hOldCursor );可是,即使做了这样的修改后,代码也不能改变光标形状。我要怎么做才能把光标变成一个沙漏形状,并在操作执行完后将它恢复成箭头形状呢?
=========================================================================================
最初的源代码如下:hCursor = LoadCursor( NULL, MAKEINTRESOURCE(IDC_WAIT) );
hCursor = SetCursor( hCursor );...
......SetCursor( hCursor ); // 恢复成箭头光标每一个函数调用都成功了,但是鼠标光标的形状却没有改变,我在 MSDN 中翻了一下:If your application must set the cursor while it is in a window, make sure the class cursor for the specified window's class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved. 似乎我如果不把窗口类结构中的光标句柄设为 NULL 的话,每当我移动鼠标,系统就会恢复鼠标的形状。
========================================================================================
然后我就把代码作了如下修改:// Changing cursor shape.
hOldCursor = (HCURSOR) GetClassLong( hwnd, (int) GCL_HCURSOR );
uRet = SetClassLong( hwnd, (int) GCL_HCURSOR, (LONG) NULL );
hCursor = LoadCursor( NULL, MAKEINTRESOURCE(IDC_WAIT) );
hCursor = SetCursor( hCursor );...
......// Resotre curosr shape
SetClassLong( hwnd, GCL_HCURSOR, (LONG) hOldCursor );
SetCursor( hOldCursor );可是,即使做了这样的修改后,代码也不能改变光标形状。我要怎么做才能把光标变成一个沙漏形状,并在操作执行完后将它恢复成箭头形状呢?
解决方案 »
- 【新手求助】VC如何调用Windows系统锁屏?
- 关于字符编码问题》
- 很奇怪的一个问题,关于剪切板的.
- 请问关于在NT/2000中交互式的登陆支持是由WinLogon调用GINA DLL的编程的问题!
- 我用VC做个小软件,想用他来访问那一台机子上的access数据库。如何实现?简单说就是如何对其他机子的access数据进行访问?
- 请问spy++中捕获窗口是怎么实现的?
- 我们老师今天竟然痛斥VC,说。。。
- 如何把一个以desktop为父窗口的应用程序的窗口变成我的子窗口?
- 怎么在程序中打开*.chm文件。
- 怎样在DLL中调用CFileDialog???
- stdafx.h怎么导入?
- ""号的小问题~~
这句好像有问题吧~~~
NULL应该指定LoadCursor (hInstance, szCursor);
uRet = SetClassLong( hwnd, (int) GCL_HCURSOR, (LONG) NULL );
hCursor = LoadCursor( NULL, MAKEINTRESOURCE(IDC_WAIT) );
hCursor = SetCursor( hCursor );
你的代码放在上面地方啊~~
是不是放在消息case语句里面还是int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)里面阿??