سؤال

I have a custom option page with a few options. In the CurPageChanged event, I'd like to catch which option is selected, and if a particular option is picked, prompt the user if they're sure they want to use that option. This page is the first one right after the welcome page...

procedure CreateInstallTypePage;
begin
  InstallTypePage:= CreateInputOptionPage(1, 'Installation Type', 'Specify whether this is a client installation or server installation, or both.', 'Choose an installation type:', True, False);
  InstallTypePage.Add('This is a client computer');
  InstallTypePage.Add('This is the main server computer');
  InstallTypePage.Add('This is the only computer (stand-alone)');
  InstallTypePage.Values[0]:= True;  
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  Log('CurPageChanged(' + IntToStr(CurPageID) + ') called');
  case CurPageID of
    1: begin
      if InstallTypePage.Values[1] then begin
        if MsgBox('Server installation will create a new database on this machine. Continue?', 
          mbInformation, MB_YESNO) = idYes then
        begin
          //Continue to next page
        end else begin
          //Don't continue to next page
        end;
      end;
    end;
  end;
end;

This isn't working, it doesn't prompt when the user presses Next from that page. Instead, it works when the user goes back a page. Obviously that's not what I need. How do I get this prompt to work?

هل كانت مفيدة؟

المحلول

A bit more fiddling with it got it figured out. I had to move to NextButtonClick instead of CurPageChanged, because CurPageChanged happens after the fact...

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ResultCode: Integer;
begin
  Log('NextButtonClick(' + IntToStr(CurPageID) + ') called');      
  Result := True;
  case CurPageID of   
    InstallTypePage.ID: begin
      if InstallTypePage.Values[INSTALL_SERVER] then begin
        Result:= MsgBox('Server installation will create a new database on this machine. Continue?', mbInformation, MB_YESNO) = idYes;
      end;
    end;
  end;
end;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top