【问题标题】:How can I hide Cursor in Windows? (delphi)如何在 Windows 中隐藏光标? (德尔福)
【发布时间】:2011-03-19 08:31:59
【问题描述】:

我希望我的程序能够像 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;

【问题讨论】:

    标签: windows delphi windows-xp cursor


    【解决方案1】:

    先下载一个空白游标,你可以从很多地方得到它,我从那里下载的 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;
    

    希望对你有帮助

    【讨论】:

    • 谢谢大家...!还有一件事。我无法再次显示默认光标。我尝试了最后一部分,但没有成功。
    • 它在我的电脑上工作,也许你正在使用它们范围之外的游标变量(在其他事件处理程序中,即你已经在这个事件处理程序中声明了它们,但是你正在重新声明并调用它们,最后一部分来自说 applicationOnClose事件),尝试在单元实现部分声明“cursor1,cursor2”,看看最后一部分现在是否有效?
    • 提示:使用 GetCursor() 代替 CopyIcon
    • @omair:查看我的编辑。不,不在范围之外使用它们。 @histrio:好的,我会尝试的。谢谢。
    • GetCursor() 不走运,尽管 LoadCursor(0, IDC_UPARROW) 对除 IDC_ARROW 之外的所有内容都表现良好。 :C
    猜你喜欢
    • 1970-01-01
    • 2014-07-17
    • 2014-07-08
    • 1970-01-01
    • 1970-01-01
    • 2010-09-11
    • 2011-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多