use new plug-in callbacks to avoid /NOUNLOAD

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5841 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2008-12-12 18:45:53 +00:00
parent e59407720a
commit 70f14a824c
6 changed files with 58 additions and 53 deletions

View file

@ -146,8 +146,6 @@ SectionEnd</pre></blockquote>
<p>Now that the foundations are laid, it's time to use nsDialogs. The first call must always be to nsDialogs::Create. It will create a new dialog in the page and return its <i>HWND</i> on the stack. The result must be popped from the stack to prevent stack corruption. If the result is <i>error</i>, the dialog couldn't be created.</p>
<p>nsDialogs::Create, like every other nsDialogs function but nsDialogs::Show, must always be called with /NOUNLOAD.</p>
<p>nsDialogs::Create accepts one parameter. It has a very specific function, but to keep things simple for this tutorial, it must always be 1018.</p>
<p><i>HWND</i> is a number that uniquely identifies the dialog and can be used with SendMessage, SetCtlColors and Win32 API.</p>
@ -166,7 +164,7 @@ Page instfiles
Function nsDialogsPage
<b>
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
@ -198,7 +196,7 @@ Page custom nsDialogsPage
Page instfiles
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
@ -240,7 +238,7 @@ Page instfiles
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
@ -311,7 +309,7 @@ Page instfiles
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
@ -366,7 +364,7 @@ Page instfiles
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
@ -444,7 +442,7 @@ FunctionEnd</b>
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
@ -488,7 +486,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-create"></a>Create</h3>
<p><code>nsDialogs::Create /NOUNLOAD <i>rect</i></code></p>
<p><code>nsDialogs::Create <i>rect</i></code></p>
<p>Creates a new dialog. <i>rect</i> specific the identifier of the control whose location will be mimiced. This should usually be 1018, which is control mimiced for creation of built-in pages. The Modern UI also has control 1040 for the welcome and the finish page.</p>
@ -496,7 +494,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-createcontrol"></a>CreateControl</h3>
<p><code>nsDialogs::CreateControl /NOUNLOAD <i>class</i> <i>style</i> <i>extended_style</i> <i>x</i> <i>y</i> <i>width</i> <i>height</i> <i>text</i></code></p>
<p><code>nsDialogs::CreateControl <i>class</i> <i>style</i> <i>extended_style</i> <i>x</i> <i>y</i> <i>width</i> <i>height</i> <i>text</i></code></p>
<p>Create a new control in the current dialog. A dialog must exist for this to work, so nsDialogs::Create must be called prior to this function.</p>
@ -512,7 +510,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-selectfiledialog"></a>SelectFileDialog</h3>
<p><code>nsDialogs::SelectFileDialog /NOUNLOAD <i>mode</i> <i>initial_selection</i> <i>filter</i></code></p>
<p><code>nsDialogs::SelectFileDialog <i>mode</i> <i>initial_selection</i> <i>filter</i></code></p>
<p>Displays a file selection dialog to the user. If <i>mode</i> is set to <i>save</i>, displays a file save dialog. If <i>mode</i> is set to <i>open</i>, displays a file open dialog. <i>filter</i> is a list of available file filters separated by pipes. If an empty string is passed, the default is used - <i>All Files|*.*</i>.</p>
@ -522,7 +520,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-selectfolderdialog"></a>SelectFolderDialog</h3>
<p><code>nsDialogs::SelectFolderDialog /NOUNLOAD <i>title</i> <i>initial_selection</i></code></p>
<p><code>nsDialogs::SelectFolderDialog <i>title</i> <i>initial_selection</i></code></p>
<p>Displays a directory selection dialog to the user.</p>
@ -530,7 +528,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-setrtl"></a>SetRTL</h3>
<p><code>nsDialogs::SetRTL /NOUNLOAD <i>rtl_setting</i></code></p>
<p><code>nsDialogs::SetRTL <i>rtl_setting</i></code></p>
<p>Sets right-to-left mode on or off. If <i>rtl_setting</i> is 0, it's set to off. If <i>rtl_setting</i> is 1, it's set to on. This function must be called before any calls to nsDialogs::CreateControl.</p>
@ -538,13 +536,13 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-getuserdata"></a>GetUserData</h3>
<p><code>nsDialogs::GetUserData /NOUNLOAD <i>control_HWND</i></code></p>
<p><code>nsDialogs::GetUserData <i>control_HWND</i></code></p>
<p>Returns user data associated with the control on the stack. Use nsDialogs::SetUserData to set this data.</p>
<h3><a name="ref-setuserdata"></a>SetUserData</h3>
<p><code>nsDialogs::SetUserData /NOUNLOAD <i>control_HWND</i> <i>data</i></code></p>
<p><code>nsDialogs::SetUserData <i>control_HWND</i> <i>data</i></code></p>
<p>Associates <i>data</i> with the control. Use nsDialogs::GetUserData to get this data.</p>
@ -552,7 +550,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-onback"></a>OnBack</h3>
<p><code>nsDialogs::OnBack /NOUNLOAD <i>function_address</i></code></p>
<p><code>nsDialogs::OnBack <i>function_address</i></code></p>
<p>Sets the callback function for the Back button. This function will be called when the user clicks the back button. Call Abort in this function to prevent the user from going back to the last page.</p>
@ -562,7 +560,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-onchange"></a>OnChange</h3>
<p><code>nsDialogs::OnChange /NOUNLOAD <i>control_HWND</i> <i>function_address</i></code></p>
<p><code>nsDialogs::OnChange <i>control_HWND</i> <i>function_address</i></code></p>
<p>Sets a change notification callback function for the given control. Whenever the control changes, the function will be called and the control's HWND will be waiting on its stack.</p>
@ -572,7 +570,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-onclick"></a>OnClick</h3>
<p><code>nsDialogs::OnClick /NOUNLOAD <i>control_HWND</i> <i>function_address</i></code></p>
<p><code>nsDialogs::OnClick <i>control_HWND</i> <i>function_address</i></code></p>
<p>Sets a click notification callback function for the given control. Whenever the control is clicked, the function will be called and the control's HWND will be waiting on its stack.</p>
@ -582,7 +580,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-onnotify"></a>OnNotify</h3>
<p><code>nsDialogs::OnNotify /NOUNLOAD <i>control_HWND</i> <i>function_address</i></code></p>
<p><code>nsDialogs::OnNotify <i>control_HWND</i> <i>function_address</i></code></p>
<p>Sets a notification callback function for the given control. Whenever the control receives the WM_NOTIFY message, the function will be called and the control's HWND, notification code and a pointer to the MNHDR structure will be waiting on its stack.</p>
@ -592,7 +590,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-ontimer"></a>OnTimer</h3>
<p><code>nsDialogs::OnTimer /NOUNLOAD <i>function_address</i> <i>timer_interval</i></code></p>
<p><code>nsDialogs::OnTimer <i>function_address</i> <i>timer_interval</i></code></p>
<p>Sets a timer that'd call the callback function for the given control every in a constant interval. Interval times are specified in milliseconds.</p>
@ -602,7 +600,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-killtimer"></a>KillTimer</h3>
<p><code>nsDialogs::KillTimer /NOUNLOAD <i>function_address</i></code></p>
<p><code>nsDialogs::KillTimer <i>function_address</i></code></p>
<p>Kills a previously set timer.</p>
@ -838,7 +836,7 @@ FunctionEnd
Function nsDialogsImage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error

View file

@ -15,26 +15,26 @@ Var CHECKBOX
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $0
GetFunctionAddress $0 OnBack
nsDialogs::OnBack /NOUNLOAD $0
nsDialogs::OnBack $0
${NSD_CreateButton} 0 0 100% 12u Test
Pop $BUTTON
GetFunctionAddress $0 OnClick
nsDialogs::OnClick /NOUNLOAD $BUTTON $0
nsDialogs::OnClick $BUTTON $0
${NSD_CreateText} 0 35 100% 12u hello
Pop $EDIT
GetFunctionAddress $0 OnChange
nsDialogs::OnChange /NOUNLOAD $EDIT $0
nsDialogs::OnChange $EDIT $0
${NSD_CreateCheckbox} 0 -50 100% 8u Test
Pop $CHECKBOX
GetFunctionAddress $0 OnCheckbox
nsDialogs::OnClick /NOUNLOAD $CHECKBOX $0
nsDialogs::OnClick $CHECKBOX $0
${NSD_CreateLabel} 0 40u 75% 40u "* Type `hello there` above.$\n* Click the button.$\n* Check the checkbox.$\n* Hit the Back button."
Pop $0

View file

@ -237,6 +237,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
static UINT_PTR PluginCallback(enum NSPIM msg)
{
return 0;
}
void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
HWND hwPlacementRect;
@ -244,6 +249,8 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variab
EXDLL_INIT();
extra->RegisterPluginCallback(g_hInstance, PluginCallback);
g_dialog.hwParent = hwndParent;
g_pluginParms = extra;

View file

@ -258,7 +258,7 @@ Header file for creating custom installer pages with nsDialogs
!macro __NSD_DefineControl NAME
!define NSD_Create${NAME} "nsDialogs::CreateControl /NOUNLOAD ${__NSD_${Name}_CLASS} ${__NSD_${Name}_STYLE} ${__NSD_${Name}_EXSTYLE}"
!define NSD_Create${NAME} "nsDialogs::CreateControl ${__NSD_${Name}_CLASS} ${__NSD_${Name}_STYLE} ${__NSD_${Name}_EXSTYLE}"
!macroend
@ -291,7 +291,7 @@ Header file for creating custom installer pages with nsDialogs
StrCpy $1 "${HWND}"
GetFunctionAddress $0 "${FUNCTION}"
nsDialogs::On${EVENT} /NOUNLOAD $1 $0
nsDialogs::On${EVENT} $1 $0
Pop $1
Pop $0
@ -309,7 +309,7 @@ Header file for creating custom installer pages with nsDialogs
Push $0
GetFunctionAddress $0 "${FUNCTION}"
nsDialogs::On${EVENT} /NOUNLOAD $0
nsDialogs::On${EVENT} $0
Pop $0
@ -331,7 +331,7 @@ Header file for creating custom installer pages with nsDialogs
Push $0
GetFunctionAddress $0 "${FUNCTION}"
nsDialogs::CreateTimer /NOUNLOAD $0 "${INTERVAL}"
nsDialogs::CreateTimer $0 "${INTERVAL}"
Pop $0
@ -344,7 +344,7 @@ Header file for creating custom installer pages with nsDialogs
Push $0
GetFunctionAddress $0 "${FUNCTION}"
nsDialogs::KillTimer /NOUNLOAD $0
nsDialogs::KillTimer $0
Pop $0
@ -634,11 +634,11 @@ Header file for creating custom installer pages with nsDialogs
StrCpy $R0 1018
${EndIf}
nsDialogs::Create /NOUNLOAD $R0
nsDialogs::Create $R0
Pop $R9
ReadINIStr $R0 $0 Settings RTL
nsDialogs::SetRTL /NOUNLOAD $R0
nsDialogs::SetRTL $R0
ReadINIStr $R0 $0 Settings NumFields
@ -726,7 +726,7 @@ Header file for creating custom installer pages with nsDialogs
${NSD_CreateBrowseButton} $R8u $R4u 15u $R6u ...
Pop $R8
nsDialogs::SetUserData /NOUNLOAD $R8 $R1 # remember field id
nsDialogs::SetUserData $R8 $R1 # remember field id
WriteINIStr $0 "Field $R1" HWND2 $R8
@ -747,7 +747,7 @@ Header file for creating custom installer pages with nsDialogs
${NSD_CreateBrowseButton} $R8u $R4u 15u $R6u ...
Pop $R8
nsDialogs::SetUserData /NOUNLOAD $R8 $R1 # remember field id
nsDialogs::SetUserData $R8 $R1 # remember field id
WriteINIStr $0 "Field $R1" HWND2 $R8
@ -764,7 +764,7 @@ Header file for creating custom installer pages with nsDialogs
Pop $R0
nsDialogs::GetUserData /NOUNLOAD $R0
nsDialogs::GetUserData $R0
Pop $R1
ReadINIStr $R2 $0 "Field $R1" HWND
@ -772,7 +772,7 @@ Header file for creating custom installer pages with nsDialogs
${NSD_GetText} $R2 $R3
nsDialogs::SelectFileDialog /NOUNLOAD save $R3 $R4
nsDialogs::SelectFileDialog save $R3 $R4
Pop $R3
${If} $R3 != ""
@ -785,7 +785,7 @@ Header file for creating custom installer pages with nsDialogs
Pop $R0
nsDialogs::GetUserData /NOUNLOAD $R0
nsDialogs::GetUserData $R0
Pop $R1
ReadINIStr $R2 $0 "Field $R1" HWND
@ -793,7 +793,7 @@ Header file for creating custom installer pages with nsDialogs
${NSD_GetText} $R2 $R4
nsDialogs::SelectFolderDialog /NOUNLOAD $R3 $R4
nsDialogs::SelectFolderDialog $R3 $R4
Pop $R3
${If} $R3 != error
@ -807,7 +807,7 @@ Header file for creating custom installer pages with nsDialogs
${NSD_CreateLink} $R3u $R4u $R5u $R6u $R7
Pop $R9
nsDialogs::SetUserData /NOUNLOAD $R9 $R1 # remember field id
nsDialogs::SetUserData $R9 $R1 # remember field id
${NSD_OnClick} $R9 ${UNINSTALLER_FUNCPREFIX}OnLink
@ -817,7 +817,7 @@ Header file for creating custom installer pages with nsDialogs
Pop $R0
nsDialogs::GetUserData /NOUNLOAD $R0
nsDialogs::GetUserData $R0
Pop $R1
ReadINIStr $R1 $0 "Field $R1" STATE

View file

@ -67,7 +67,7 @@ FunctionEnd
Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $DIALOG
${NSD_CreateLabel} 0u 0u 100% 9u "nsDialogs timer example"

View file

@ -195,10 +195,10 @@ FunctionEnd
Function nsDialogsWelcome
nsDialogs::Create /NOUNLOAD 1044
nsDialogs::Create 1044
Pop $DIALOG
nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
Pop $IMAGECTL
StrCpy $0 $PLUGINSDIR\welcome.bmp
@ -207,12 +207,12 @@ Function nsDialogsWelcome
SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
Pop $HEADLINE
SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
nsDialogs::CreateControl /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."
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."
Pop $TEXT
SetCtlColors $DIALOG "" 0xffffff
@ -238,28 +238,28 @@ Function nsDialogsDirectory
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 0
nsDialogs::Create /NOUNLOAD 1018
nsDialogs::Create 1018
Pop $DIALOG
nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
Pop $HEADLINE
SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
Pop $TEXT
nsDialogs::CreateControl /NOUNLOAD EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
Pop $DIRECTORY
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
GetFunctionAddress $0 DirChange
nsDialogs::OnChange /NOUNLOAD $DIRECTORY $0
nsDialogs::OnChange $DIRECTORY $0
System::Call shlwapi::SHAutoComplete(i$DIRECTORY,i${SHACF_FILESYSTEM})
nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
Pop $FREESPACE
Call UpdateFreeSpace