如何在 Windows 中隐藏光标? (德尔福)

发布于 2024-09-10 13:41:38 字数 1298 浏览 4 评论 0原文

我希望我的程序能够像 Team Player 一样工作。多只鼠标、多光标但只有一个焦点。但问题是我无法隐藏默认光标。我只希望它不可见。 到目前为止,这仅适用于我的应用程序。

ShowCursor(false);

Screen.Cursor:=crNone;

没有办法隐藏整个系统的光标(直到我关闭应用程序)?


编辑: 这不起作用:

procedure myShowCursor(Show :boolean);
var cursor1, cursor2: HCursor;
begin
 cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('blank\blank.cur');
 if Show then
  SetSystemCursor(cursor1, OCR_NORMAL)
 else
 SetSystemCursor(cursor2, OCR_NORMAL);
end;

这起作用:(但我不能完全使用它)

procedure myShowCursor;
var cursor1, cursor2: HCursor;
begin
 cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('blank\blank.cur');

 SetSystemCursor(cursor2, OCR_NORMAL);
 SetSystemCursor(cursor1, OCR_NORMAL)
end;

已解决:通过 SystemParametersInfo 恢复系统光标

procedure TForm1.myShowCursor(Show :boolean);
var cursor1: HCursor;
begin
 cursor1 := LoadCursorFromFile('blank\blank.cur');
 if Show then
  SystemParametersInfo(SPI_SETCURSORS,0,0,WM_SETTINGCHANGE or SPIF_UPDATEINIFILE )
 else
 SetSystemCursor(cursor1, OCR_NORMAL);
end;

I want my program to work sort of like Team Player. Multi mice, multi cursor but only one focus. But the problem is I can't hide the default cursor. I only want it to be invisible.
So far this works inside my application only.

ShowCursor(false);

and

Screen.Cursor:=crNone;

Is there a way to hide the cursor for the entire system (just until I close my application)?


EDIT:
This doesn't work:

procedure myShowCursor(Show :boolean);
var cursor1, cursor2: HCursor;
begin
 cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('blank\blank.cur');
 if Show then
  SetSystemCursor(cursor1, OCR_NORMAL)
 else
 SetSystemCursor(cursor2, OCR_NORMAL);
end;

This works: (but I can't exactly use this)

procedure myShowCursor;
var cursor1, cursor2: HCursor;
begin
 cursor1 :=CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('blank\blank.cur');

 SetSystemCursor(cursor2, OCR_NORMAL);
 SetSystemCursor(cursor1, OCR_NORMAL)
end;

SOLVED: restored system cursors by SystemParametersInfo

procedure TForm1.myShowCursor(Show :boolean);
var cursor1: HCursor;
begin
 cursor1 := LoadCursorFromFile('blank\blank.cur');
 if Show then
  SystemParametersInfo(SPI_SETCURSORS,0,0,WM_SETTINGCHANGE or SPIF_UPDATEINIFILE )
 else
 SetSystemCursor(cursor1, OCR_NORMAL);
end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱要勇敢去追 2024-09-17 13:41:38

首先下载一个空白光标,很多地方都可以得到,我是从
http://pc.autons.net/stuff/blanks/blank.zip
,提取空白.zip,然后将空白.cur 复制并粘贴到所需位置(在本例中,我将其保存到“c:\blank.cur”)
然后尝试这段代码:

var cursor1, cursor2: HCursor;
begin
 cursor1 := CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('c:\blank.cur');
 SetSystemCursor(cursor2, OCR_NORMAL);//to hide cursor
 Sleep(2000);
 SetSystemCursor(cursor1, OCR_NORMAL);//to show cursor again
end;

希望这有帮助

first download a blank cursor, you can get it from many places,i downloaded it from
http://pc.autons.net/stuff/blanks/blank.zip
,extact blank.zip then copy and paste blank.cur to a desired location(i am saving it to 'c:\blank.cur' for this example)
then try this code:

var cursor1, cursor2: HCursor;
begin
 cursor1 := CopyIcon(Screen.Cursors[crDefault]);
 cursor2 := LoadCursorFromFile('c:\blank.cur');
 SetSystemCursor(cursor2, OCR_NORMAL);//to hide cursor
 Sleep(2000);
 SetSystemCursor(cursor1, OCR_NORMAL);//to show cursor again
end;

hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文