Inno Setup event that is generated when folder is browsed on TInputDirWizardPage?

ぐ巨炮叔叔 提交于 2020-01-14 04:09:31

问题


I'm using a custom TInputDirWizardPage to input three different target folders for my installation.

When the first folder is changed, I'd like to automatically change the 3rd folder's path. Is it possible to create an event that occurs when the Browse button is used for the first folder and a specific folder is selected? If so, is it also possible to change the 3rd folder's path programmatically?


回答1:


You can override TInputDirWizardPage.Buttons[0].OnClick event handler:

var
  DirPage: TInputDirWizardPage;
  PrevFirstButtonClick: TNotifyEvent;

procedure FirstButtonClick(Sender: TObject);
var
  PrevValue: string;
begin
  PrevValue := DirPage.Values[0];

  { Call remembered handler }
  PrevFirstButtonClick(Sender);

  if DirPage.Values[0] <> PrevValue then
  begin
    { And do whatever you want to do when the value changes }
    MsgBox(Format('Value changed from "%s" to "%s".', [PrevValue, DirPage.Values[0]]),
      mbInformation, MB_OK);
  end;
end;

procedure InitializeWizard();
begin
  DirPage := CreateInputDirPage(
    wpSelectDir, SetupMessage(msgWizardSelectDir), '', '', False, '');
  { add directory input page items }
  DirPage.Add('Path to Apache:');
  DirPage.Add('Path to PHP:');
  DirPage.Add('Path to Server Files:');

  { Remember the standard handler }
  PrevFirstButtonClick := DirPage.Buttons[0].OnClick;
  { And assign our override } 
  DirPage.Buttons[0].OnClick := @FirstButtonClick;
end;

The code needs Unicode version of Inno Setup. Calling DirPage.Buttons[0].OnClick strangely does not work in Ansi version.



来源:https://stackoverflow.com/questions/53797410/inno-setup-event-that-is-generated-when-folder-is-browsed-on-tinputdirwizardpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!