长时间执行操作,显示等待图标.

长时间执行操作,显示等待图标.

如果程序中,需要进行长时间等待操作,可以显示等待图标,这样可以给人更好的体验.
在WIN32中,主要有SetCursor()函数来设置显示的图标.
在MSDN中对该函数的说明为:
HCURSOR SetCursor(
HCURSOR hCursor
);
hCursor
[in] Handle to the cursor. The cursor must have been created by the CreateCursor or loaded by the LoadCursor or LoadImage function. If this parameter is NULL, the cursor is removed from the screen.

The width and height of the cursor must be the values returned by the GetSystemMetrics function for SM_CXCURSOR and SM_CYCURSOR.

而里面需要用到LoadCursor()函数,
HCURSOR LoadCursor(
HINSTANCE hInstance,
LPCTSTR lpCursorName
);
To use one of the Microsoft Win32 predefined cursors, the application must set the hInstance parameter to NULL and the lpCursorName parameter to a specific value. The following table shows the possible values. This parameter must be set to one of these values.

Value Description
IDC_APPSTARTING
Standard arrow and small hourglass.

IDC_ARROW
Standard arrow.

IDC_CROSS
Crosshair.

IDC_HAND
Hand.

IDC_HELP
Arrow and question mark.

IDC_ICON
Obsolete.

IDC_NO
Slashed circle.

IDC_SIZE
Obsolete; use IDC_SIZEALL.

IDC_SIZEALL
Four-pointed arrow pointing north, south, east, and west.

IDC_SIZENESW
Double-pointed arrow pointing northeast and southwest.

IDC_SIZENS
Double-pointed arrow pointing north and south.

IDC_SIZENWSE
Double-pointed arrow pointing northwest and southeast.

IDC_SIZEWE
Double-pointed arrow pointing west and east.

IDC_UPARROW
Vertical arrow.

IDC_WAIT
Hourglass.

因此要用显示系统的等待图标,可以为
SetCursor(LoadCursor(NULL, IDC_WAIT));
然后在结束的时候再把默认图标切换回来.
SetCursor(LoadCursor(NULL, IDC_ARROW));

你可能感兴趣的:(Microsoft)