gpt4 book ai didi

c++ - 如何在 Windows API 中更改系统范围内的多个游标

转载 作者:行者123 更新时间:2023-11-27 23:43:41 26 4
gpt4 key购买 nike

我正在尝试使用 SetSystemCursor 替换多个系统游标。我的第一个调用更改了 OCR_NORMAL 的光标,但后续调用不起作用。

HCURSOR hWaitCur = LoadCursor(NULL, IDC_WAIT);
HCURSOR cursorCopy = CopyCursor(hWaitCur);

SetSystemCursor(cursorCopy, OCR_NORMAL); // This works

// Not working
SetSystemCursor(cursorCopy, OCR_APPSTARTING);
SetSystemCursor(cursorCopy, OCR_CROSS);
SetSystemCursor(cursorCopy, OCR_HAND);
SetSystemCursor(cursorCopy, OCR_HELP);
SetSystemCursor(cursorCopy, OCR_IBEAM);
SetSystemCursor(cursorCopy, OCR_NO);
SetSystemCursor(cursorCopy, OCR_WAIT);

一次更新多个系统游标的正确方法是什么?

最佳答案

来自docs (由我强调):

The system destroys hcur by calling the DestroyCursor function. Therefore, hcur cannot be a cursor loaded using the LoadCursor function. To specify a cursor loaded from a resource, copy the cursor using the CopyCursor function, then pass the copy to SetSystemCursor.

所以每次调用前都需要复制:

SetSystemCursor(CopyCursor(hWaitCur), OCR_NORMAL);
SetSystemCursor(CopyCursor(hWaitCur), OCR_APPSTARTING);
SetSystemCursor(CopyCursor(hWaitCur), OCR_CROSS);
SetSystemCursor(CopyCursor(hWaitCur), OCR_HAND);
SetSystemCursor(CopyCursor(hWaitCur), OCR_HELP);
SetSystemCursor(CopyCursor(hWaitCur), OCR_IBEAM);
SetSystemCursor(CopyCursor(hWaitCur), OCR_NO);
SetSystemCursor(CopyCursor(hWaitCur), OCR_WAIT);

关于c++ - 如何在 Windows API 中更改系统范围内的多个游标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52492374/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com