Contenu
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Rechercher
Login
Qui est en ligne?
Nous avons 166 invités en ligne
Navigation
Home Code source Inno Setup Scan a disk path or an entire disk with Inno Setup - Cancel button
Les plus récents
Articles vedettes
Joomla 1.5 Featured Articles
Navigation
Home Code source Inno Setup Scan a disk path or an entire disk with Inno Setup - Cancel button
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Scan a disk path or an entire disk with Inno Setup - Cancel button Envoyer
Note des utilisateurs: / 11
MauvaisTrès bien 
Code source - Inno Setup
Écrit par Thomas   
Lundi, 01 Juin 2009 19:30
Index de l'article
Scan a disk path or an entire disk with Inno Setup
Progress page
Cancel button
Example script
Toutes les pages

 

As mentioned earlier, the scan could take a very long time, maybe even several hours. It is unacceptable not to provide an option to cancelling the process.

The Cancel button is actually there, stuck on the installation wizard. It's just not visible while the progress page works.

To get the button back, it needs to be made visible:

  1. WizardForm.CancelButton.Visible := TRUE;

Once the Cancel button is visible it automatically gets its function back. Of course, it can't interrupt the directory reading function while files are read in and being processed. When Cancel is clicked, the directory scan happily carries on, and as soon as it is finished Inno Setup asks if the installation is to be aborted.

This still is not how it should be. The scan should be stopped immediately, or at least as quickly as possible.

Inno Setup's script engine provides an event function for the Cancel button: CancelButtonClick ().

With a simple message box identical to the 'Exit Setup' confirmation message I tricked the user in believing that they see Inno Setup's original confirmation:

  1. procedure CancelButtonClick (CurPageID: Integer; var Cancel, Confirm: Boolean);
  2. // No confirmation message, because we roll our own.
  3. // The base idea has been nicked from
  4. // http://www.vincenzo.net/isxkb/index.php?title=No_%27Exit_Setup%27_message .
  5. // The only difference to Inno Setup's 'Exit Setup' message box is its title,
  6. // but that's only a minor cosmetic glitch.
  7. begin
  8. Confirm := FALSE;
  9. if (MsgBox (SetupMessage (msgExitSetupMessage),
  10. mbConfirmation, MB_YESNO) = IDYES) then
  11. begin
  12. bExitSetup := TRUE;
  13. end;
  14. end;
  15.  

The difference between this 'Exit Setup' confirmation box and Inno Setup's own can be seen in the window title.

Exit Setup with correct title bar

Exit Setup - Setup

The original confirmation message box is called 'Exit Setup' (image on the top) while mine contains the title of the setup (bottom image), which is 'Setup' by default. Although this is a fairly good working solution already, I was not happy with this difference.

Since Inno Setup uses the Windows API MessageBox (), I was sure it can be used too to correct the window title. I found the declaration for Pascal script on the ISXKB under MessageBox () and nicked it from there:

[Code]
function MessageBox (hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer; external 'MessageBoxA@user32.dll stdcall';

Pascal seems a bit picky when it comes to types, hence I didn't want to bother with all those required conversions and looked up the parameter constants in the file WinUser.h from the Windows SDK instead. Here's the relevant excerpt from that file:

  1. /*
  2.  * MessageBox() Flags
  3.  */
  4. #define MB_OK                       0x00000000L
  5. #define MB_OKCANCEL                 0x00000001L
  6. #define MB_ABORTRETRYIGNORE         0x00000002L
  7. #define MB_YESNOCANCEL              0x00000003L
  8. #define MB_YESNO                    0x00000004L
  9. #define MB_RETRYCANCEL              0x00000005L
  10. #if(WINVER >= 0x0500)
  11. #define MB_CANCELTRYCONTINUE        0x00000006L
  12. #endif /* WINVER >= 0x0500 */
  13.  
  14.  
  15. #define MB_ICONHAND                 0x00000010L
  16. #define MB_ICONQUESTION             0x00000020L
  17. #define MB_ICONEXCLAMATION          0x00000030L
  18. #define MB_ICONASTERISK             0x00000040L
  19.  
  20. #if(WINVER >= 0x0400)
  21. #define MB_USERICON                 0x00000080L
  22. #define MB_ICONWARNING              MB_ICONEXCLAMATION
  23. #define MB_ICONERROR                MB_ICONHAND
  24. #endif /* WINVER >= 0x0400 */
  25.  
  26. #define MB_ICONINFORMATION          MB_ICONASTERISK
  27. #define MB_ICONSTOP                 MB_ICONHAND
  28.  
  29. #define MB_DEFBUTTON1               0x00000000L
  30. #define MB_DEFBUTTON2               0x00000100L
  31. #define MB_DEFBUTTON3               0x00000200L
  32. #if(WINVER >= 0x0400)
  33. #define MB_DEFBUTTON4               0x00000300L
  34. #endif /* WINVER >= 0x0400 */
  35.  
  36. #define MB_APPLMODAL                0x00000000L
  37. #define MB_SYSTEMMODAL              0x00001000L
  38. #define MB_TASKMODAL                0x00002000L
  39. #if(WINVER >= 0x0400)
  40. #define MB_HELP                     0x00004000L // Help Button
  41. #endif /* WINVER >= 0x0400 */
  42.  
  43. #define MB_NOFOCUS                  0x00008000L
  44. #define MB_SETFOREGROUND            0x00010000L
  45. #define MB_DEFAULT_DESKTOP_ONLY     0x00020000L
  46.  
  47. #if(WINVER >= 0x0400)
  48. #define MB_TOPMOST                  0x00040000L
  49. #define MB_RIGHT                    0x00080000L
  50. #define MB_RTLREADING               0x00100000L
  51.  
  52.  
  53. #endif /* WINVER >= 0x0400 */
  54.  

I used the values directly and changed the function accordingly:

  1. procedure CancelButtonClick (CurPageID: Integer; var Cancel, Confirm: Boolean);
  2. begin
  3. Confirm := FALSE;
  4. if (MessageBox (0, SetupMessage (msgExitSetupMessage),
  5. SetupMessage (msgExitSetupTitle), 4 + 32) = 6) then
  6. begin
  7. bExitSetup := TRUE;
  8. end;
  9. end;
  10.  

The outcome is an example Inno Setup script that scans the entire C: drive. If the user gets bored of watching the scan they can press the Cancel button and terminate the installer.

Scan for files with a Cancel button

Scan for files and Cancel pressed

 



Mise à jour le Jeudi, 15 Octobre 2009 15:26
 
You need to login or register to post comments.
Discutez de ceci sur le forum. (5 posts)
Discutez de (5 posts)
Re: Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 20:10:17
Not sure I understand what a "registry directory" is
#2352
Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 17:13:28
hi
this above scanning drive inno setup code can be use just like installaing files to registry directory
#2351
Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 17:11:28
#2350
Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 17:11:28
hi
this above scanning drive inno setup code can be use just like installaing files to registry directory
#2349
Scan a disk path or an entire disk with Inno Setup
Sep 25 2012 06:22:16
This is very helpful post. Thanks for this dude. It really helps me a lot.

*** some spam removed *** (by George)
#1454