welcome.nsi 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. !include MUI.nsh
  2. !include LogicLib.nsh
  3. !include nsDialogs.nsh
  4. !include WinMessages.nsh
  5. !include FileFunc.nsh
  6. Name "nsDialogs Welcome"
  7. OutFile "nsDialogs Welcome.exe"
  8. Page custom nsDialogsWelcome
  9. Page custom nsDialogsDirectory
  10. !insertmacro MUI_PAGE_INSTFILES
  11. !insertmacro MUI_LANGUAGE English
  12. Var DIALOG
  13. Var HEADLINE
  14. Var TEXT
  15. Var IMAGECTL
  16. Var IMAGE
  17. Var DIRECTORY
  18. Var FREESPACE
  19. Var HEADLINE_FONT
  20. Function .onInit
  21. CreateFont $HEADLINE_FONT "$(^Font)" "14" "700"
  22. InitPluginsDir
  23. File /oname=$PLUGINSDIR\welcome.bmp "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp"
  24. FunctionEnd
  25. Function HideControls
  26. LockWindow on
  27. GetDlgItem $0 $HWNDPARENT 1028
  28. ShowWindow $0 ${SW_HIDE}
  29. GetDlgItem $0 $HWNDPARENT 1256
  30. ShowWindow $0 ${SW_HIDE}
  31. GetDlgItem $0 $HWNDPARENT 1035
  32. ShowWindow $0 ${SW_HIDE}
  33. GetDlgItem $0 $HWNDPARENT 1037
  34. ShowWindow $0 ${SW_HIDE}
  35. GetDlgItem $0 $HWNDPARENT 1038
  36. ShowWindow $0 ${SW_HIDE}
  37. GetDlgItem $0 $HWNDPARENT 1039
  38. ShowWindow $0 ${SW_HIDE}
  39. GetDlgItem $0 $HWNDPARENT 1045
  40. ShowWindow $0 ${SW_NORMAL}
  41. LockWindow off
  42. FunctionEnd
  43. Function ShowControls
  44. LockWindow on
  45. GetDlgItem $0 $HWNDPARENT 1028
  46. ShowWindow $0 ${SW_NORMAL}
  47. GetDlgItem $0 $HWNDPARENT 1256
  48. ShowWindow $0 ${SW_NORMAL}
  49. GetDlgItem $0 $HWNDPARENT 1035
  50. ShowWindow $0 ${SW_NORMAL}
  51. GetDlgItem $0 $HWNDPARENT 1037
  52. ShowWindow $0 ${SW_NORMAL}
  53. GetDlgItem $0 $HWNDPARENT 1038
  54. ShowWindow $0 ${SW_NORMAL}
  55. GetDlgItem $0 $HWNDPARENT 1039
  56. ShowWindow $0 ${SW_NORMAL}
  57. GetDlgItem $0 $HWNDPARENT 1045
  58. ShowWindow $0 ${SW_HIDE}
  59. LockWindow off
  60. FunctionEnd
  61. Function nsDialogsWelcome
  62. nsDialogs::Create 1044
  63. Pop $DIALOG
  64. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
  65. Pop $IMAGECTL
  66. StrCpy $0 $PLUGINSDIR\welcome.bmp
  67. System::Call 'user32::LoadImage(p 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE})p.s'
  68. Pop $IMAGE
  69. SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
  70. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
  71. Pop $HEADLINE
  72. SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  73. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "nsDialogs is the next generation of user interfaces in NSIS. It gives the developer full control over custom pages. Some of the features include control text containing variables, callbacks directly into script functions and creation of any type of control. Create boring old edit boxes or load some external library and create custom controls with no need of creating your own plug-in.$\r$\n$\r$\nUnlike InstallOptions, nsDialogs doesn't use INI files to communicate with the script. By interacting directly with the script, nsDialogs can perform much faster without the need of costly, old and inefficient INI operations. Direct interaction also allows direct calls to functions defined in the script and removes the need of conversion functions like Io2Nsis.$\r$\n$\r$\nHit the Next button to see how it all fits into a mock directory page."
  74. Pop $TEXT
  75. SetCtlColors $DIALOG "" 0xffffff
  76. SetCtlColors $HEADLINE "" 0xffffff
  77. SetCtlColors $TEXT "" 0xffffff
  78. Call HideControls
  79. nsDialogs::Show
  80. Call ShowControls
  81. System::Call gdi32::DeleteObject(p$IMAGE)
  82. FunctionEnd
  83. !define SHACF_FILESYSTEM 1
  84. Function nsDialogsDirectory
  85. !insertmacro MUI_HEADER_TEXT "Choose Install Location" "Choose the folder in which to install $(^NameDA)."
  86. GetDlgItem $0 $HWNDPARENT 1
  87. EnableWindow $0 0
  88. nsDialogs::Create 1018
  89. Pop $DIALOG
  90. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
  91. Pop $HEADLINE
  92. SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  93. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
  94. Pop $TEXT
  95. nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
  96. Pop $DIRECTORY
  97. SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
  98. GetFunctionAddress $0 DirChange
  99. nsDialogs::OnChange $DIRECTORY $0
  100. System::Call shlwapi::SHAutoComplete(p$DIRECTORY,i${SHACF_FILESYSTEM})
  101. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
  102. Pop $FREESPACE
  103. Call UpdateFreeSpace
  104. nsDialogs::Show
  105. FunctionEnd
  106. Function UpdateFreeSpace
  107. ${GetRoot} $INSTDIR $0
  108. StrCpy $1 " bytes"
  109. System::Call kernel32::GetDiskFreeSpaceEx(tr0,*l,*l,*l.r0)
  110. ${If} $0 > 1024
  111. ${OrIf} $0 < 0
  112. System::Int64Op $0 / 1024
  113. Pop $0
  114. StrCpy $1 "kb"
  115. ${If} $0 > 1024
  116. ${OrIf} $0 < 0
  117. System::Int64Op $0 / 1024
  118. Pop $0
  119. StrCpy $1 "mb"
  120. ${If} $0 > 1024
  121. ${OrIf} $0 < 0
  122. System::Int64Op $0 / 1024
  123. Pop $0
  124. StrCpy $1 "gb"
  125. ${EndIf}
  126. ${EndIf}
  127. ${EndIf}
  128. SendMessage $FREESPACE ${WM_SETTEXT} 0 "STR:Free space: $0$1"
  129. FunctionEnd
  130. Function DirChange
  131. Pop $0 # dir hwnd
  132. GetDlgItem $0 $HWNDPARENT 1
  133. System::Call user32::GetWindowText(p$DIRECTORY,t.d,i${NSIS_MAX_STRLEN})
  134. ${If} ${FileExists} $INSTDIR\makensis.exe
  135. EnableWindow $0 1
  136. ${Else}
  137. EnableWindow $0 0
  138. ${EndIf}
  139. Call UpdateFreeSpace
  140. FunctionEnd
  141. Section
  142. SectionEnd