diff --git a/Contrib/nsDialogs/Readme.html b/Contrib/nsDialogs/Readme.html index d21a4855..58a5a90b 100644 --- a/Contrib/nsDialogs/Readme.html +++ b/Contrib/nsDialogs/Readme.html @@ -36,7 +36,6 @@ code
Compiling the last script and running it results in an empty page which is not very useful. So now we'll add some controls to it to. To do so, we'll use ${NSD_Create*} macros from nsDialogs.nsh. Each of those macros takes 5 parameters - x, y, width, height and text. Each macro also returns one value on the stack, which is the new control's HWND. Like the dialogs HWND, it must be popped from the stack and saved.
+Compiling the last script and running it results in an empty page which is not very useful. So now we'll add some controls to it to. To do so, we'll use ${NSD_Create*} macros from nsDialogs.nsh. Each of those macros takes 5 parameters - x, y, width, height and text. Each macro also returns one value on the stack, which is the new control's HWND. Like the dialogs HWND, it must be popped from the stack and saved.
Each of the measurements that the macros take can use one of three unit types - pixels, dialog units or percentage of the dialog's size. It can also be negative to indicate it should be measured from the end. To use dialog units, the measurement must be suffixed with the letter u. To use percentage, the measurement must be suffixed with the percentage sign - %. Any other suffix, or no suffix, means pixels.
@@ -228,7 +244,7 @@ Section SectionEnd -Available control types that can be created with ${NSD_Create*} are:
+Available control types that can be created with ${NSD_Create*} are:
Now that we have some controls that the user can interact with, it's time to see what the user actually does with them. For that, we'll first add a leave callback function to our page. In that function, we'll query the state of the text control we've created and display it to the user. To do so, we'll use the ${NSD_GetText} macro. Use the ${NSD_GetState} macro for RadioButton and CheckBox controls.
+Now that we have some controls that the user can interact with, it's time to see what the user actually does with them. For that, we'll first add a leave callback function to our page. In that function, we'll query the state of the text control we've created and display it to the user. To do so, we'll use the ${NSD_GetText} macro. Use the ${NSD_GetState} macro for RadioButton and CheckBox controls.
-Note that not all controls support ${NSD_GetText} and some require special handling with specific messages defined in WinMessages.nsh. For example, the ListBox control requires usage of LB_GETCURSEL and LB_GETTEXT. With time, the library of macros in nsDialogs.nsh will fill with more and more macros that'll handle more cases like this.
+Note that not all controls support ${NSD_GetText} and some require special handling with specific messages defined in WinMessages.nsh. For example, the ListBox control requires usage of LB_GETCURSEL and LB_GETTEXT. With time, the library of macros in nsDialogs.nsh will fill with more and more macros that'll handle more cases like this.
!include nsDialogs.nsh !include LogicLib.nsh @@ -306,7 +322,7 @@ SectionEnd
One of the more exciting new features of nsDialogs is callback function notification of changes to the dialog. nsDialogs can call a function defined in a script in response to a user action such as changing of a text field or click of a button. To make nsDialogs notify us of events, we'll use ${NSD_OnClick} and ${NSD_OnChange}. Not every control supports both of the events. For example, there's nothing to notify about labels.
+One of the more exciting new features of nsDialogs is callback function notification of changes to the dialog. nsDialogs can call a function defined in a script in response to a user action such as changing of a text field or click of a button. To make nsDialogs notify us of events, we'll use ${NSD_OnClick} and ${NSD_OnChange}. Not every control supports both of the events. For example, there's nothing to notify about labels.
When the callback function is called, the control's HWND will be waiting on the stack and must be popped to prevent stack corruption. In this simple example, this is not so useful. But in case of a bigger script where several controls are associated with the same callback function, the HWND can shed some light on which control originated the event.
@@ -376,7 +392,7 @@ SectionEndSo far we have a page that has some basic input controls. But what happens when the user goes to the next page and comes back? With the current code, the user's input will not be remembered. To remember, we'll use the already present leave callback function to store the user's choice in variables and pass these values when creating the controls the next time. For a better example, we'll also add a checkbox to the page and use ${NSD_GetState} and ${NSD_SetState} to get and set its state.
+So far we have a page that has some basic input controls. But what happens when the user goes to the next page and comes back? With the current code, the user's input will not be remembered. To remember, we'll use the already present leave callback function to store the user's choice in variables and pass these values when creating the controls the next time. For a better example, we'll also add a checkbox to the page and use ${NSD_GetState} and ${NSD_SetState} to get and set its state.
For clarity, we'll remove some of the notifications from the previous step.
@@ -425,7 +441,10 @@ Function nsDialogsPage ${If} $Checkbox_State == ${BST_CHECKED} ${NSD_Check} $Checkbox - ${EndIf} + ${EndIf} + + # alternative for the above ${If}: + #${NSD_SetState} $Checkbox_State nsDialogs::Show @@ -444,14 +463,6 @@ Section SectionEnd -Use the following syntax to set the focus to a specified control.
- -${NSD_SetFocus} hwnd_of_control
nsDialogs::CreateControl /NOUNLOAD class style extended_style x y width height text
nsDialogs::CreateControl /NOUNLOAD class style extended_style x y width height text
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.
@@ -556,6 +567,119 @@ SectionEndReturns nothing.
+nsDialogs.nsh contains a lot of macros that can make nsDialogs usage a lot easier. Below is a description of each of those macros including purpose, syntax, input and output.
+ +${NSD_Create*} x y width height text
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.
+ +Available variants:
+ +Returns the new dialog's HWND on the stack or error.
+ +${NSD_OnBack} function_address
See OnBack for more details.
+ + + +${NSD_OnChange} function_address
See OnChange for more details.
+ +See Real-time Notification for usage example.
+ +${NSD_OnClick} function_address
See OnClick for more details.
+ +${NSD_OnNotify} function_address
See OnNotify for more details.
+ +${NSD_GetText} control_HWND output_variable
Retrieves the text of a control and stores it into output_variable. Especially useful for textual controls.
+ +See Control State for usage example.
+ +${NSD_SetText} control_HWND text
Sets the text of a control.
+ +${NSD_GetState} control_HWND output_variable
Retrieves the state of a check box or a radio button control. Possible outputs are ${BST_CHECKED} and ${BST_UNCHECKED}.
+ +See Memory for usage example.
+ +${NSD_SetState} control_HWND state
Sets the state of a check box or a radio button control. Possible values for state are ${BST_CHECKED} and ${BST_UNCHECKED}.
+ +See Memory for usage example.
+ +${NSD_Check} control_HWND
Checks a check box or a radio button control. Same as calling ${NSD_SetState} with ${BST_CHECKED}.
+ +${NSD_Uncheck} control_HWND
Unchecks a check box or a radio button control. Same as calling ${NSD_SetState} with ${BST_UNCHECKED}.
+ +See Memory for usage example.
+ +${NSD_SetFocus} control_HWND
Sets focus to a control.
+