Search code examples
inno-setuppascalscript

Inno Setup update disk space after changing components checkbox state from code


I got a list of components (applications) that I can select to install (by default they are all checked) and all of those components got ExtraDiskSpaceRequired. On the start, I dynamically change which applications should be checked or unchecked depending on are they installed and some other conditions.

Now problem is when I check components (TNewCheckListBox items) from code on start "Disk space required" label is not updated until I change state of some checkbox from the list by mouse or keyboard.

I tried to fix it with:

  • WizardForm.Repaint and other methods like that
  • Changing state of checkboxes when that page is being shown
  • Trying to send Space button down and up with SendInput from Windows API but it returns 0 (not pressed). I called SendInput in CurPageChanged function when wpSelectComponents is shown and from Timer

    Code I used for SendInput:

    type
        TKeyboardInput = record
            Itype: DWORD;    
            wVk: WORD;
            wScan: WORD;
            dwFlags: DWORD;
            time: DWORD;
            dwExtraInfo: DWORD;
        end;
    
    function SendInput(nInputs: UINT; pInputs: TKeyboardInput;
        cbSize: Integer): UINT; 
        external 'SendInput@user32.dll stdcall';
    
    function SendKeyPressed(KeyCode: Word): Boolean;
    var
        InputDown: TKeyboardInput;
        InputUp: TKeyboardInput;
    begin
        Result := False;
    
        InputDown.Itype := 1;
        InputDown.wVk := KeyCode;
        InputDown.wScan := 0;
        InputDown.time := 0;
        InputDown.dwFlags := 0;
    
        InputUp.Itype := 1;
        InputUp.wVk := KeyCode;
        InputUp.wScan := 0;
        InputUp.time := 0;
        InputUp.dwFlags := 2;
    
        MsgBox(IntToStr(SendInput(1, InputDown, SizeOf(InputDown))),
          mbInformation, MB_OK);
        Result := SendInput(1, InputUp, SizeOf(InputUp)) = 1;
        if Result then
        begin
            MsgBox('Test2', mbInformation, MB_OK);
        end;
    end;
    

Any idea how can I solve this?

Example by default:

  • CheckBox1 5MB checked
  • CheckBox2 7MB checked
  • Disk space label 12MB

Example after changing state by code on start:

  • CheckBox1 5MB checked
  • CheckBox2 7MB unchecked

  • Disk space label is still 12MB until I change state of checkbox by mouse or keyboard

Note: I am using Inno Setup 5.6.1 (u) and can not update for now.


Solution

  • Trigger TNewCheckListBox.OnClickCheck event after you update the state of the list checkboxes:

    WizardForm.ComponentsList.OnClickCheck(WizardForm.ComponentsList);