Blame | Last modification | View Log | RSS feed
!include "MUI2.nsh"!include "LogicLib.nsh"!include "nsDialogs.nsh"; Simple PAGES based on MUI2 that contains 1, 2 or 3 edit boxes with labels and a titles;; Usage Use the !insertmacro to insert the pages in the order you require as with standard pages; There are 3 macros one for pages with a single edit box, one for a page with 2 edit boxes and another for one with 3 edit boxes; !insertmacro VIX_PAGE_EDIT1 "Label1" $Var1; !insertmacro VIX_PAGE_EDIT2 "Label1" $Var1 "Label2" $Var2; !insertmacro VIX_PAGE_EDIT3 "Label1" $Var1 "Label2" $Var2 "Label3" $Var3;; They will display a dialog with the appropriate number of edit boxes with the assoctaied label next to it; The edit boxes and labels are fixed size & position so labels need to checked that they are not truncated; The VarN variables are used to supply the current value when the dialog is displayed and also return what was entered (or default if not changed);; The Macros can be used multiple times to display multiple edit pages;; The Dialogs use several defines for messages.; !define VIX_PAGE_EDIT_TEXT The (short) Text in the top section of the Dialog (in the same section as the VIX icon); Defaults to "Edit Data"; !define VIX_PAGE_EDIT_SUBTEXT The (short) SubText in the top section of the Dialog under the Text (in the same section as the VIX icon); Defaults to "Enter Requested Data"; !define VIX_PAGE_EDIT_TITLE The Title that appears in the main body of the dialog above the edit fields. Used to detail whart is required to be entered.; Defaults to "Enter Required fields";; Example; !include "MUI2.nsh"; !include "VixPageEditDialogs.nsh"; Var OracleSID; Var OracleUser; Var OraclePasswd; !insertmacro MUI_PAGE_WELCOME; !define VIX_PAGE_EDIT_TEXT "Oracle Login Details"; !define VIX_PAGE_EDIT_SUBTEXT "Enter the Oracle connection details"; !define VIX_PAGE_EDIT_TITLE "Enter the Oracle Database SID and associated user name and password to log on with"; !insertmacro VIX_PAGE_EDIT3 "Oracle SID:" $OracleSID "User name:" $OracleUser "Password:" $OraclePasswd; !insertmacro MUI_PAGE_DIRECTORY; !insertmacro MUI_PAGE_INSTFILES;==========================================================================; VIX_PAGE_EDIT1 Label1 Var1;==========================================================================!macro VIX_PAGE_EDIT1 Label1 Var1!insertmacro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID; Sets the defines for the var and label to use for single edit box!insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS!insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 1 "${Label1}" "${Var1}"; define the var to save the edit box control toVar Text1${VIX_PAGE_EDIT_UNIQUE_ID}; now run the page!insertmacro _VIX_PAGE_EDIT!insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS!undef VIX_PAGE_EDIT_UNIQUE_ID!macroend;==========================================================================; VIX_PAGE_EDIT2 Label1 Var1 Label2 Var2;==========================================================================!macro VIX_PAGE_EDIT2 Label1 Var1 Label2 Var2!insertmacro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID; Sets the defines for the var and label to use for single edit box!insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS!insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 1 "${Label1}" "${Var1}"!insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 2 "${Label2}" "${Var2}"; define the var to save the edit box control toVar Text1${VIX_PAGE_EDIT_UNIQUE_ID}Var Text2${VIX_PAGE_EDIT_UNIQUE_ID}; now run the page!insertmacro _VIX_PAGE_EDIT!insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS!undef VIX_PAGE_EDIT_UNIQUE_ID!macroend;==========================================================================; VIX_PAGE_EDIT3 Label1 Var1 Label2 Var2 Label3 Var3;==========================================================================!macro VIX_PAGE_EDIT3 Label1 Var1 Label2 Var2 Label3 Var3!insertmacro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID; Sets the defines for the var and label to use for single edit box!insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS!insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 1 "${Label1}" "${Var1}"!insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 2 "${Label2}" "${Var2}"!insertmacro _DEFINE_VIX_PAGE_EDIT_VAR 3 "${Label3}" "${Var3}"; define the var to save the edit box control toVar Text1${VIX_PAGE_EDIT_UNIQUE_ID}Var Text2${VIX_PAGE_EDIT_UNIQUE_ID}Var Text3${VIX_PAGE_EDIT_UNIQUE_ID}; now run the page!insertmacro _VIX_PAGE_EDIT!insertmacro _UNDEF_ALL_VIX_PAGE_EDIT_VARS!undef VIX_PAGE_EDIT_UNIQUE_ID!macroend;==========================================================================; INTERNAL MACROS;==========================================================================; defines a unique id so this dialog can be used multiple times!macro _DEFINE_VIX_PAGE_EDIT_UNIQUE_ID!ifdef VIX_PAGE_EDIT_UNIQUE_ID!undef VIX_PAGE_EDIT_UNIQUE_ID!endif!define VIX_PAGE_EDIT_UNIQUE_ID _VIX_PAGE_EDIT_${__LINE__}!macroend!macro _DEFINE_VIX_PAGE_EDIT_VAR Num Label Variable!define _VIX_PAGE_EDIT_LABEL${Num} "${Label}"!define _VIX_PAGE_EDIT_VAR${Num} "${Variable}"!macroend!macro _UNDEF_ALL_VIX_PAGE_EDIT_VARS!ifdef _VIX_PAGE_EDIT_LABEL1!undef _VIX_PAGE_EDIT_LABEL1!endif!ifdef _VIX_PAGE_EDIT_VAR1!undef _VIX_PAGE_EDIT_VAR1!endif!ifdef _VIX_PAGE_EDIT_LABEL2!undef _VIX_PAGE_EDIT_LABEL2!endif!ifdef _VIX_PAGE_EDIT_VAR2!undef _VIX_PAGE_EDIT_VAR2!endif!ifdef _VIX_PAGE_EDIT_LABEL3!undef _VIX_PAGE_EDIT_LABEL3!endif!ifdef _VIX_PAGE_EDIT_VAR3!undef _VIX_PAGE_EDIT_VAR3!endif!macroend!macro _VIX_PAGE_EDITPage custom PageFunc${VIX_PAGE_EDIT_UNIQUE_ID} LeaveFunc${VIX_PAGE_EDIT_UNIQUE_ID}Var Dialog${VIX_PAGE_EDIT_UNIQUE_ID}Function PageFunc${VIX_PAGE_EDIT_UNIQUE_ID}Push $0 ; save $0nsDialogs::Create 1018Pop $Dialog${VIX_PAGE_EDIT_UNIQUE_ID}${If} $Dialog${VIX_PAGE_EDIT_UNIQUE_ID} == errorAbort${EndIf}!ifdef VIX_PAGE_EDIT_TEXT & VIX_PAGE_EDIT_SUBTEXT!insertmacro MUI_HEADER_TEXT "${VIX_PAGE_EDIT_TEXT}" "${VIX_PAGE_EDIT_SUBTEXT}"!undef VIX_PAGE_EDIT_TEXT!undef VIX_PAGE_EDIT_SUBTEXT!else ifdef VIX_PAGE_EDIT_TEXT!insertmacro MUI_HEADER_TEXT "${VIX_PAGE_EDIT_TEXT}" "Enter Requested Data"!undef VIX_PAGE_EDIT_TEXT!else ifdef VIX_PAGE_EDIT_SUBTEXT!insertmacro MUI_HEADER_TEXT "Edit Data" "${VIX_PAGE_HEADER_SUBTEXT}"!undef VIX_PAGE_EDIT_SUBTEXT!else!insertmacro MUI_HEADER_TEXT "Edit Data" "Enter Requested Data"!endif!ifdef VIX_PAGE_EDIT_TITLE${NSD_CreateLabel} 0 0 100% 36u "${VIX_PAGE_EDIT_TITLE}"!undef VIX_PAGE_EDIT_TITLE!else${NSD_CreateLabel} 0 0 100% 36u "Enter Required fields"!endifPop $0!ifdef _VIX_PAGE_EDIT_VAR1${NSD_CreateLabel} 0 41u 19% 12u "${_VIX_PAGE_EDIT_LABEL1}"Pop $0${NSD_CreateText} 20% 40u 80% 12u "${_VIX_PAGE_EDIT_VAR1}"Pop $Text1${VIX_PAGE_EDIT_UNIQUE_ID}!endif!ifdef _VIX_PAGE_EDIT_VAR2${NSD_CreateLabel} 0 71u 19% 12u "${_VIX_PAGE_EDIT_LABEL2}"Pop $0${NSD_CreateText} 20% 70u 80% 12u "${_VIX_PAGE_EDIT_VAR2}"Pop $Text2${VIX_PAGE_EDIT_UNIQUE_ID}!endif!ifdef _VIX_PAGE_EDIT_VAR3${NSD_CreateLabel} 0 101u 19% 12u "${_VIX_PAGE_EDIT_LABEL3}"Pop $0${NSD_CreateText} 20% 100u 80% 12u "${_VIX_PAGE_EDIT_VAR3}"Pop $Text3${VIX_PAGE_EDIT_UNIQUE_ID}!endifnsDialogs::ShowPop $0FunctionEndFunction LeaveFunc${VIX_PAGE_EDIT_UNIQUE_ID}!ifdef _VIX_PAGE_EDIT_VAR1${NSD_GetText} $Text1${VIX_PAGE_EDIT_UNIQUE_ID} ${_VIX_PAGE_EDIT_VAR1}!endif!ifdef _VIX_PAGE_EDIT_VAR2${NSD_GetText} $Text2${VIX_PAGE_EDIT_UNIQUE_ID} ${_VIX_PAGE_EDIT_VAR2}!endif!ifdef _VIX_PAGE_EDIT_VAR3${NSD_GetText} $Text3${VIX_PAGE_EDIT_UNIQUE_ID} ${_VIX_PAGE_EDIT_VAR3}!endifFunctionEnd!macroend