如何在 Windows 中隐藏光标? (德尔福)
我希望我的程序能够像 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先下载一个空白光标,很多地方都可以得到,我是从
http://pc.autons.net/stuff/blanks/blank.zip
,提取空白.zip,然后将空白.cur 复制并粘贴到所需位置(在本例中,我将其保存到“c:\blank.cur”)
然后尝试这段代码:
希望这有帮助
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:
hope this helps