home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Programming / nsis-2.46-setup.exe / Examples / nsDialogs / welcome.nsi < prev   
Encoding:
Text File  |  2008-12-12  |  9.3 KB  |  321 lines

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