如何在 Windows 中隐藏光标?(德尔福)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3305708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I hide Cursor in Windows? (delphi)
提问by Dian
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.
我希望我的程序能够像Team Player一样工作。多鼠标,多光标,但只有一个焦点。但问题是我无法隐藏默认光标。我只希望它是隐形的。到目前为止,这只适用于我的应用程序。
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
已解决:通过 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;
回答by Omair Iqbal
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:
首先下载一个空白光标,你可以从很多地方得到它,我从http://pc.autons.net/stuff/blanks/blank.zip下载它 ,extact blank.zip 然后复制并粘贴 blank.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;
hope this helps
希望这可以帮助