开发者

How to change mouse cursor inside Inno setup?

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 开发者_C百科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.


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!


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);


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);  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜