如何在 Inno 设置中更改鼠标光标?

发布于 2024-09-14 10:41:00 字数 273 浏览 6 评论 0原文

我使用 Inno 安装程序创建了一个安装程序,在安装过程中,我进行了一些冗长的操作来检查系统上的某些值(注册表项、一些文件...),在此期间没有向用户显示任何界面,我执行了所有操作这在InitializeSetup函数中。

我想知道的是,在进行所有这些检查时是否可以更改鼠标指针,以便用户知道正在发生某些事情。

我想我可以创建一个dll并从inno调用dll内的函数来更改光标,但我不想制作一个单独的dll,我在想是否有一种方法可以仅使用pascal脚本来做到这一点。

感谢您的帮助。

I created a setup using Inno installer, during the setup, I made some lengthly operations to check certain values over the system (registry keys, some files...) and during that time no interface is displayed to the user, I do all of this inside InitializeSetup function.

What I would like to know is if I can change the mouse pointer while I'm doing all of those checks, so the user knows that something is happening.

I think I can create a dll and call from inno the functions inside the dll that change the cursor, but I don't want to make a separate dll, I was wandering if there is a way to do it just using pascal scripting.

Thanks for the help.

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

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

发布评论

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

评论(3

夕色琉璃 2024-09-21 10:41:00

也许 Inno Setup 的最新版本中发生了一些变化,但我无法从 Mirtheil 那里得到答案来工作。

相反,我想出了这个:

procedure SetControlCursor(oCtrl: TControl; oCurs: TCursor);
var 
  i     : Integer;
  oCmp  : TComponent;
begin
  oCtrl.Cursor := oCurs;
  for i := 0 to oCtrl.ComponentCount-1 do
  begin
    oCmp := oCtrl.Components[i];
    if oCmp is TControl then
    begin
      SetControlCursor(TControl(oCmp), oCurs);
    end;
  end;
end;

设置沙漏光标:

SetControlCursor(WizardForm, crHourGlass);    

重置沙漏光标:

SetControlCursor(WizardForm, crDefault);  

希望这对某人有帮助!

Maybe something changed in recent versions of Inno Setup but I could not get the answer from Mirtheil to work.

Instead I figured out this one:

procedure SetControlCursor(oCtrl: TControl; oCurs: TCursor);
var 
  i     : Integer;
  oCmp  : TComponent;
begin
  oCtrl.Cursor := oCurs;
  for i := 0 to oCtrl.ComponentCount-1 do
  begin
    oCmp := oCtrl.Components[i];
    if oCmp is TControl then
    begin
      SetControlCursor(TControl(oCmp), oCurs);
    end;
  end;
end;

Set an hourglass cursor:

SetControlCursor(WizardForm, crHourGlass);    

Reset the hourglass cursor:

SetControlCursor(WizardForm, crDefault);  

Hope this helps someone!

半寸时光 2024-09-21 10:41:00

取自: http://www.vincenzo.net/isxkb/index.php?title=Cursor_-_Change_the_mouse_cursor_of_WizardForm

procedure SetControlCursor(control: TWinControl; cursor: TCursor);
var i:Integer;
    wc: TWinControl;
begin
  if (not (control = nil)) then begin
    control.Cursor := cursor;
    try
      for i:=0 to control.ControlCount-1 do begin
        wc := TWinControl(control.Controls[i]);
        if (NOT(wc = nil)) then
          SetControlCursor(wc, cursor)
        else
          control.Controls[i].Cursor := cursor;
      end; {for}
    finally

    end;{try}
  end;{if}
end;{procedure SetControlCursor}

并将其设置为沙漏:

SetControlCursor(WizardForm, crHourGlass);

将其设置回正常状态:

SetControlCursor(WizardForm, crDefault);

Taken from: http://www.vincenzo.net/isxkb/index.php?title=Cursor_-_Change_the_mouse_cursor_of_WizardForm

procedure SetControlCursor(control: TWinControl; cursor: TCursor);
var i:Integer;
    wc: TWinControl;
begin
  if (not (control = nil)) then begin
    control.Cursor := cursor;
    try
      for i:=0 to control.ControlCount-1 do begin
        wc := TWinControl(control.Controls[i]);
        if (NOT(wc = nil)) then
          SetControlCursor(wc, cursor)
        else
          control.Controls[i].Cursor := cursor;
      end; {for}
    finally

    end;{try}
  end;{if}
end;{procedure SetControlCursor}

And to set it to the hourglass:

SetControlCursor(WizardForm, crHourGlass);

To set it back to normal:

SetControlCursor(WizardForm, crDefault);
oО清风挽发oО 2024-09-21 10:41:00

结合 @mirtheil 和 @Sirp 的答案中的好部分,这是我认为的最佳解决方案:

procedure SetControlCursor(Control: TControl; Cursor: TCursor);
var 
  I: Integer;
begin
  Control.Cursor := Cursor;
  if Control is TWinControl then
  begin
    for I := 0 to TWinControl(Control).ControlCount - 1 do
    begin
      SetControlCursor(TWinControl(Control).Controls[I], Cursor);
    end;
  end;
end;

设置沙漏光标:

SetControlCursor(WizardForm, crHourGlass);    

重置默认光标:

SetControlCursor(WizardForm, crDefault);  

Combining the good parts from the answers by @mirtheil and @Sirp, this is imo the optimal solution:

procedure SetControlCursor(Control: TControl; Cursor: TCursor);
var 
  I: Integer;
begin
  Control.Cursor := Cursor;
  if Control is TWinControl then
  begin
    for I := 0 to TWinControl(Control).ControlCount - 1 do
    begin
      SetControlCursor(TWinControl(Control).Controls[I], Cursor);
    end;
  end;
end;

Set the hourglass cursor:

SetControlCursor(WizardForm, crHourGlass);    

Reset the default cursor:

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