home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 November / PCWNOV07.iso / Software / Freeware / NSIS 2.29 / nsis-2.29-setup.exe / Examples / nsDialogs / welcome.nsi < prev   
Encoding:
Text File  |  2007-07-14  |  9.4 KB  |  321 lines

  1. !include MUI.nsh
  2. !include LogicLib.nsh
  3. !include WinMessages.nsh
  4. !include FileFunc.nsh
  5.  
  6. !insertmacro GetRoot
  7.  
  8. Name "nsDialogs Welcome"
  9. OutFile "nsDialogs Welcome.exe"
  10.  
  11. Page custom nsDialogsWelcome
  12. Page custom nsDialogsDirectory
  13. !insertmacro MUI_PAGE_INSTFILES
  14.  
  15. !insertmacro MUI_LANGUAGE English
  16.  
  17. !define WS_EX_CLIENTEDGE    0x00000200
  18.  
  19. !define WS_CHILD            0x40000000
  20. !define WS_VISIBLE          0x10000000
  21. !define WS_DISABLED         0x08000000
  22. !define WS_CLIPSIBLINGS     0x04000000
  23. !define WS_MAXIMIZE         0x01000000
  24. !define WS_VSCROLL          0x00200000
  25. !define WS_HSCROLL          0x00100000
  26. !define WS_GROUP            0x00020000
  27. !define WS_TABSTOP          0x00010000
  28.  
  29. !define ES_LEFT             0x00000000
  30. !define ES_CENTER           0x00000001
  31. !define ES_RIGHT            0x00000002
  32. !define ES_MULTILINE        0x00000004
  33. !define ES_UPPERCASE        0x00000008
  34. !define ES_LOWERCASE        0x00000010
  35. !define ES_PASSWORD         0x00000020
  36. !define ES_AUTOVSCROLL      0x00000040
  37. !define ES_AUTOHSCROLL      0x00000080
  38. !define ES_NOHIDESEL        0x00000100
  39. !define ES_OEMCONVERT       0x00000400
  40. !define ES_READONLY         0x00000800
  41. !define ES_WANTRETURN       0x00001000
  42. !define ES_NUMBER           0x00002000
  43.  
  44. !define SS_LEFT             0x00000000
  45. !define SS_CENTER           0x00000001
  46. !define SS_RIGHT            0x00000002
  47. !define SS_ICON             0x00000003
  48. !define SS_BLACKRECT        0x00000004
  49. !define SS_GRAYRECT         0x00000005
  50. !define SS_WHITERECT        0x00000006
  51. !define SS_BLACKFRAME       0x00000007
  52. !define SS_GRAYFRAME        0x00000008
  53. !define SS_WHITEFRAME       0x00000009
  54. !define SS_USERITEM         0x0000000A
  55. !define SS_SIMPLE           0x0000000B
  56. !define SS_LEFTNOWORDWRAP   0x0000000C
  57. !define SS_OWNERDRAW        0x0000000D
  58. !define SS_BITMAP           0x0000000E
  59. !define SS_ENHMETAFILE      0x0000000F
  60. !define SS_ETCHEDHORZ       0x00000010
  61. !define SS_ETCHEDVERT       0x00000011
  62. !define SS_ETCHEDFRAME      0x00000012
  63. !define SS_TYPEMASK         0x0000001F
  64. !define SS_REALSIZECONTROL  0x00000040
  65. !define SS_NOPREFIX         0x00000080
  66. !define SS_NOTIFY           0x00000100
  67. !define SS_CENTERIMAGE      0x00000200
  68. !define SS_RIGHTJUST        0x00000400
  69. !define SS_REALSIZEIMAGE    0x00000800
  70. !define SS_SUNKEN           0x00001000
  71. !define SS_EDITCONTROL      0x00002000
  72. !define SS_ENDELLIPSIS      0x00004000
  73. !define SS_PATHELLIPSIS     0x00008000
  74. !define SS_WORDELLIPSIS     0x0000C000
  75. !define SS_ELLIPSISMASK     0x0000C000
  76.  
  77. !define BS_PUSHBUTTON       0x00000000
  78. !define BS_DEFPUSHBUTTON    0x00000001
  79. !define BS_CHECKBOX         0x00000002
  80. !define BS_AUTOCHECKBOX     0x00000003
  81. !define BS_RADIOBUTTON      0x00000004
  82. !define BS_3STATE           0x00000005
  83. !define BS_AUTO3STATE       0x00000006
  84. !define BS_GROUPBOX         0x00000007
  85. !define BS_USERBUTTON       0x00000008
  86. !define BS_AUTORADIOBUTTON  0x00000009
  87. !define BS_PUSHBOX          0x0000000A
  88. !define BS_OWNERDRAW        0x0000000B
  89. !define BS_TYPEMASK         0x0000000F
  90. !define BS_LEFTTEXT         0x00000020
  91. !define BS_TEXT             0x00000000
  92. !define BS_ICON             0x00000040
  93. !define BS_BITMAP           0x00000080
  94. !define BS_LEFT             0x00000100
  95. !define BS_RIGHT            0x00000200
  96. !define BS_CENTER           0x00000300
  97. !define BS_TOP              0x00000400
  98. !define BS_BOTTOM           0x00000800
  99. !define BS_VCENTER          0x00000C00
  100. !define BS_PUSHLIKE         0x00001000
  101. !define BS_MULTILINE        0x00002000
  102. !define BS_NOTIFY           0x00004000
  103. !define BS_FLAT             0x00008000
  104. !define BS_RIGHTBUTTON      ${BS_LEFTTEXT}
  105.  
  106. !define LR_DEFAULTCOLOR     0x0000
  107. !define LR_MONOCHROME       0x0001
  108. !define LR_COLOR            0x0002
  109. !define LR_COPYRETURNORG    0x0004
  110. !define LR_COPYDELETEORG    0x0008
  111. !define LR_LOADFROMFILE     0x0010
  112. !define LR_LOADTRANSPARENT  0x0020
  113. !define LR_DEFAULTSIZE      0x0040
  114. !define LR_VGACOLOR         0x0080
  115. !define LR_LOADMAP3DCOLORS  0x1000
  116. !define LR_CREATEDIBSECTION 0x2000
  117. !define LR_COPYFROMRESOURCE 0x4000
  118. !define LR_SHARED           0x8000
  119.  
  120. !define IMAGE_BITMAP        0
  121. !define IMAGE_ICON          1
  122. !define IMAGE_CURSOR        2
  123. !define IMAGE_ENHMETAFILE   3
  124.  
  125. Var DIALOG
  126. Var HEADLINE
  127. Var TEXT
  128. Var IMAGECTL
  129. Var IMAGE
  130. Var DIRECTORY
  131. Var FREESPACE
  132.  
  133. Var HEADLINE_FONT
  134.  
  135. Function .onInit
  136.  
  137.     CreateFont $HEADLINE_FONT "$(^Font)" "14" "700"
  138.  
  139.     InitPluginsDir
  140.     File /oname=$PLUGINSDIR\welcome.bmp "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp"
  141.  
  142. FunctionEnd
  143.  
  144. Function HideControls
  145.  
  146.     LockWindow on
  147.     GetDlgItem $0 $HWNDPARENT 1028
  148.     ShowWindow $0 ${SW_HIDE}
  149.  
  150.     GetDlgItem $0 $HWNDPARENT 1256
  151.     ShowWindow $0 ${SW_HIDE}
  152.  
  153.     GetDlgItem $0 $HWNDPARENT 1035
  154.     ShowWindow $0 ${SW_HIDE}
  155.  
  156.     GetDlgItem $0 $HWNDPARENT 1037
  157.     ShowWindow $0 ${SW_HIDE}
  158.  
  159.     GetDlgItem $0 $HWNDPARENT 1038
  160.     ShowWindow $0 ${SW_HIDE}
  161.  
  162.     GetDlgItem $0 $HWNDPARENT 1039
  163.     ShowWindow $0 ${SW_HIDE}
  164.  
  165.     GetDlgItem $0 $HWNDPARENT 1045
  166.     ShowWindow $0 ${SW_NORMAL}
  167.     LockWindow off
  168.  
  169. FunctionEnd
  170.  
  171. Function ShowControls
  172.  
  173.     LockWindow on
  174.     GetDlgItem $0 $HWNDPARENT 1028
  175.     ShowWindow $0 ${SW_NORMAL}
  176.  
  177.     GetDlgItem $0 $HWNDPARENT 1256
  178.     ShowWindow $0 ${SW_NORMAL}
  179.  
  180.     GetDlgItem $0 $HWNDPARENT 1035
  181.     ShowWindow $0 ${SW_NORMAL}
  182.  
  183.     GetDlgItem $0 $HWNDPARENT 1037
  184.     ShowWindow $0 ${SW_NORMAL}
  185.  
  186.     GetDlgItem $0 $HWNDPARENT 1038
  187.     ShowWindow $0 ${SW_NORMAL}
  188.  
  189.     GetDlgItem $0 $HWNDPARENT 1039
  190.     ShowWindow $0 ${SW_NORMAL}
  191.  
  192.     GetDlgItem $0 $HWNDPARENT 1045
  193.     ShowWindow $0 ${SW_HIDE}
  194.     LockWindow off
  195.  
  196. FunctionEnd
  197.  
  198. Function nsDialogsWelcome
  199.  
  200.     nsDialogs::Create /NOUNLOAD 1044
  201.     Pop $DIALOG
  202.  
  203.     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
  204.     Pop $IMAGECTL
  205.  
  206.     StrCpy $0 $PLUGINSDIR\welcome.bmp
  207.     System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i.s'
  208.     Pop $IMAGE
  209.     
  210.     SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
  211.  
  212.     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
  213.     Pop $HEADLINE
  214.  
  215.     SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  216.  
  217.     nsDialogs::CreateItem /NOUNLOAD 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."
  218.     Pop $TEXT
  219.  
  220.     SetCtlColors $DIALOG "" 0xffffff
  221.     SetCtlColors $HEADLINE "" 0xffffff
  222.     SetCtlColors $TEXT "" 0xffffff
  223.  
  224.     Call HideControls
  225.  
  226.     nsDialogs::Show
  227.  
  228.     Call ShowControls
  229.  
  230.     System::Call gdi32::DeleteObject(i$IMAGE)
  231.  
  232. FunctionEnd
  233.  
  234. !define SHACF_FILESYSTEM 1
  235.  
  236. Function nsDialogsDirectory
  237.  
  238.     !insertmacro MUI_HEADER_TEXT "Choose Install Location" "Choose the folder in which to install $(^NameDA)."
  239.  
  240.     GetDlgItem $0 $HWNDPARENT 1
  241.     EnableWindow $0 0
  242.  
  243.     nsDialogs::Create /NOUNLOAD 1018
  244.     Pop $DIALOG
  245.  
  246.     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
  247.     Pop $HEADLINE
  248.  
  249.     SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  250.  
  251.     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
  252.     Pop $TEXT
  253.  
  254.     nsDialogs::CreateItem /NOUNLOAD EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
  255.     Pop $DIRECTORY
  256.  
  257.     SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
  258.  
  259.     GetFunctionAddress $0 DirChange
  260.     nsDialogs::OnChange /NOUNLOAD $DIRECTORY $0
  261.  
  262.     System::Call shlwapi::SHAutoComplete(i$DIRECTORY,i${SHACF_FILESYSTEM})
  263.  
  264.     nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
  265.     Pop $FREESPACE
  266.  
  267.     Call UpdateFreeSpace
  268.  
  269.     nsDialogs::Show
  270.  
  271. FunctionEnd
  272.  
  273. Function UpdateFreeSpace
  274.  
  275.     ${GetRoot} $INSTDIR $0
  276.     StrCpy $1 " bytes"
  277.  
  278.     System::Call kernel32::GetDiskFreeSpaceEx(tr0,*l,*l,*l.r0)
  279.  
  280.     ${If} $0 > 1024
  281.     ${OrIf} $0 < 0
  282.         System::Int64Op $0 / 1024
  283.         Pop $0
  284.         StrCpy $1 "kb"
  285.         ${If} $0 > 1024
  286.         ${OrIf} $0 < 0
  287.             System::Int64Op $0 / 1024
  288.             Pop $0
  289.             StrCpy $1 "mb"
  290.             ${If} $0 > 1024
  291.             ${OrIf} $0 < 0
  292.                 System::Int64Op $0 / 1024
  293.                 Pop $0
  294.                 StrCpy $1 "gb"
  295.             ${EndIf}
  296.         ${EndIf}
  297.     ${EndIf}
  298.  
  299.     SendMessage $FREESPACE ${WM_SETTEXT} 0 "STR:Free space: $0$1"
  300.  
  301. FunctionEnd
  302.  
  303. Function DirChange
  304.  
  305.     GetDlgItem $0 $HWNDPARENT 1
  306.  
  307.     System::Call user32::GetWindowText(i$DIRECTORY,t.d,i${NSIS_MAX_STRLEN})
  308.  
  309.     ${If} ${FileExists} $INSTDIR\makensis.exe
  310.         EnableWindow $0 1
  311.     ${Else}
  312.         EnableWindow $0 0
  313.     ${EndIf}
  314.  
  315.     Call UpdateFreeSpace
  316.  
  317. FunctionEnd
  318.  
  319. Section
  320. SectionEnd
  321.