2010-08-13 129 views
2

我使用Inno安装程序创建了一个安装程序,在安装过程中,我做了一些长时间的操作来检查系统上的某些值(注册表项,某些文件...),并且在那段时间没有界面显示给用户,所有这些都在InitializeSetup函数里面。如何更改Inno安装程序中的鼠标光标?

我想知道的是,如果我在进行所有这些检查时可以更改鼠标指针,那么用户就知道发生了某些事情。

我想我可以创建一个dll并从inno调用dll中改变光标的函数,但我不想做一个单独的dll,如果有一种方法只是使用pascal脚本。

感谢您的帮助。

回答

4

来自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); 
+0

谢谢你,代码的作用就像一个魅力,只是一个简单的说明,你不能在InitializeSetup中使用它,因为它会给出一个错误:“试图在创建之前访问WizardForm”在我的情况下,我只需将我的代码移动到InitializeWizard并解决了问题。 – Vic 2010-08-13 23:33:23

4

也许一些在最新版本的改变InnoSetup,但我无法从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); 

希望这可以帮助别人!