tests/nsis3/share/doc/nsis/Docs/nsDialogs/Readme.html

Summary

Maintainability
Test Coverage
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>nsDialogs</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
body { color: #000000; background-color: #ffffff; }
b { color: red; }
code { margin-left: 1.2em; padding: 0.5em; background-color: #f0f0f0; }
span.inlcod i { padding: 0px 0.2em; color: #222222; font-family: monospace; font-style: normal; }
blockquote pre { background-color: #fcfcfc; font-family: monospace; }
abbr { font-variant: none; cursor: help; }
</style>
</head>
<body>

<h1>NSIS nsDialogs Plug-in</h1>
<p><i>Next generation of user interface design</i></p>

<h2>Table of Contents</h2>

<ul>
<li><a href="#intro">Introduction</a></li>
<li>
<a href="#step">Step-by-Step Tutorial</a>
<ul>
<li><a href="#step-page">Custom Page</a></li>
<li><a href="#step-add">Adding Controls</a></li>
<li><a href="#step-state">Control State</a></li>
<li><a href="#step-notify">Real-time Notification</a></li>
<li><a href="#step-memory">Memory</a></li>
</ul>
</li>
<li>
<a href="#ref">Function Reference</a>
<ul>
<li><a href="#ref-create">Create</a></li>
<li><a href="#ref-createcontrol">CreateControl</a></li>
<li><a href="#ref-show">Show</a></li>
<li><a href="#ref-selectfiledialog">SelectFileDialog</a></li>
<li><a href="#ref-selectfolderdialog">SelectFolderDialog</a></li>
<li><a href="#ref-setrtl">SetRTL</a></li>
<li><a href="#ref-getuserdata">GetUserData</a></li>
<li><a href="#ref-setuserdata">SetUserData</a></li>
<li><a href="#ref-onback">OnBack</a></li>
<li><a href="#ref-onchange">OnChange</a></li>
<li><a href="#ref-onclick">OnClick</a></li>
<li><a href="#ref-onnotify">OnNotify</a></li>
<li><a href="#ref-createtimer">CreateTimer</a></li>
<li><a href="#ref-killtimer">KillTimer</a></li>
</ul>
</li>
<li>
<a href="#mref">Macro Reference</a>
<ul>
<li><a href="#mref-create">NSD_Create*</a></li>
<li><a href="#mref-onback">NSD_OnBack</a>, <a href="#mref-onchange">NSD_OnChange</a>, <a href="#mref-onclick">NSD_OnClick</a>, <a href="#mref-onnotify">NSD_OnNotify</a></li>
<li><a href="#mref-setfocus">NSD_SetFocus</a></li>
<li><a href="#mref-createtimer">NSD_CreateTimer</a>, <a href="#mref-killtimer">NSD_KillTimer</a></li>
<li><a href="#mref-addstyle">NSD_AddStyle</a>, <a href="#mref-addexstyle">NSD_AddExStyle</a></li>
<li><a href="#mref-gettext">NSD_GetText</a>, <a href="#mref-settext">NSD_SetText</a></li>
<li>Text, Password &amp; Number: 
<a href="#mref-settextlimit">NSD_Edit_SetTextLimit</a>, 
<a href="#mref-edsetro">NSD_Edit_SetReadOnly</a>,
<a href="#mref-edsetcuebanner">NSD_Edit_SetCueBannerText</a>
</li>
<li>RichEdit: 
<a href="#mref-richsettextlimit">NSD_RichEd_SetTextLimit</a>, 
<a href="#mref-richseteventmask">NSD_RichEd_SetEventMask</a>, 
<a href="#mref-richsetbkclr">NSD_RichEd_SetCustomBackgroundColor</a>
</li>
<li>CheckBox &amp; RadioButton: 
<a href="#mref-getstate">NSD_GetState</a>, 
<a href="#mref-setstate">NSD_SetState</a>, 
<a href="#mref-check">NSD_Check</a>, 
<a href="#mref-uncheck">NSD_Uncheck</a>
</li>
<li>ComboBox &amp; DropList: 
<a href="#mref-cbaddstring">NSD_CB_AddString</a>, 
<a href="#mref-cbinsstring">NSD_CB_PrependString, NSD_CB_AppendString, NSD_CB_InsertString</a>, 
<a href="#mref-cbselectstring">NSD_CB_SelectString</a>, 
<a href="#mref-cbgetcount">NSD_CB_GetCount</a>
</li>
<li>ListBox: 
<a href="#mref-lbaddstring">NSD_LB_AddString</a>, 
<a href="#mref-lbinsstring">NSD_LB_PrependString, NSD_LB_AppendString, NSD_LB_InsertString</a>, 
<a href="#mref-lbdelstring">NSD_LB_DelString</a>, 
<a href="#mref-lbdelitem">NSD_LB_DelItem</a>, 
<a href="#mref-lbclear">NSD_LB_Clear</a>, 
<a href="#mref-lbgetcount">NSD_LB_GetCount</a>, 
<a href="#mref-lbselectstring">NSD_LB_SelectString</a>, 
<a href="#mref-lbgetselection">NSD_LB_GetSelection</a>
</li>
<li>Animation: 
<a href="#mref-animopenfile">NSD_Anim_OpenFile</a>, 
<a href="#mref-animplay">NSD_Anim_Play</a>, 
<a href="#mref-animstop">NSD_Anim_Stop</a>
</li>
<li>HTrackBar &amp; VTrackBar: 
<a href="#mref-trackgetpos">NSD_TrackBar_GetPos</a>, 
<a href="#mref-tracksetpos">NSD_TrackBar_SetPos</a>, 
<a href="#mref-tracksetrmin">NSD_TrackBar_SetRangeMin</a>, 
<a href="#mref-tracksetrmax">NSD_TrackBar_SetRangeMax</a>, 
<a href="#mref-tracksetticfr">NSD_TrackBar_SetTicFreq</a>
</li>
<li>UpDown: 
<a href="#mref-udsetbuddy">NSD_UD_SetBuddy</a>, 
<a href="#mref-udgetpos">NSD_UD_GetPos</a>, 
<a href="#mref-udsetpos">NSD_UD_SetPos</a>,
<a href="#mref-udsetpackedrange">NSD_UD_SetPackedRange</a>
</li>
<li>HotKey: 
<a href="#mref-hkgethk">NSD_HK_GetHotKey</a>, <a href="#mref-hksethk">NSD_HK_SetHotKey</a>
</li>
<li>Bitmap: 
<a href="#mref-setimage">NSD_SetImage</a>, 
<a href="#mref-setsimage">NSD_SetStretchedImage</a>, 
<a href="#mref-clearimage">NSD_ClearImage</a>, 
<a href="#mref-freeimage">NSD_FreeImage</a>
</li>
<li>Icon: 
<a href="#mref-seticon">NSD_SetIcon</a>, 
<a href="#mref-seticonfrominstaller">NSD_SetIconFromInstaller</a>, 
<a href="#mref-clearicon">NSD_ClearIcon</a>, 
<a href="#mref-freeicon">NSD_FreeIcon</a>
</li>
</ul>
</li>
<li><a href="#faq">FAQ</a></li>
</ul>

<h2><a name="intro"></a>Introduction</h2>

<p>nsDialogs allows creation of custom pages in the installer. On top of the built-in pages, nsDialogs can create pages with any type of controls in any order and arrangement. It can create everything from a simple page with one label to form which reacts to user's actions. <a href="../Modern UI 2/Readme.html">Modern UI 2</a>, for example, uses nsDialogs to create the welcome and finish pages.</p>

<p>nsDialogs is a NSIS plug-in, introduced in version 2.29 as a replacement for <a href="../InstallOptions/Readme.html">InstallOptions</a>. nsDialogs doesn't use INI files, so it's way faster than InstallOptions. Integration with the script is tighter and more natural - creating controls is done using plug-in functions and notification is done by directly calling a function in the script. Unlike InstallOptions, there isn't a predefined set of available control type and by providing a lower level access to Windows API, every type of control can be created and pages can be more customizable.</p>

<p>The same thing that makes nsDialogs more flexible can also make it more complicated for users with no knowledge of Win32 API. This is solved by creating a library of predefined functions, defined in script, that allow creation and handling of controls. This way, novices get easy access to the flexibility, while advanced users still get access to the <a href="http://msdn.microsoft.com/en-us/library/bb773169">core functionality</a> by modifying the library or simply avoid using it.</p>

<h2><a name="step"></a>Step-by-Step Tutorial</h2>

<h3><a name="step-page"></a>Custom Page</h3>

<p>Before you can start adding controls you need to create a nsDialogs custom page. nsDialogs pages can only be created in a custom page's creator function, not in sections nor regular functions. Lets create a basic script with a empty nsDialogs page as our skeleton:</p>

<blockquote><pre><b>!include LogicLib.nsh</b>

Name nsDialogs
OutFile nsDialogs.exe
XPStyle on

<b>
Var Dialog

Page custom nsDialogsPage</b>
Page instfiles

<b>Function nsDialogsPage
    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    nsDialogs::Show
FunctionEnd</b>

Section
SectionEnd</pre></blockquote>
<span class="inlcod">
<p>The first call must always be to <i>nsDialogs::Create</i>. 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 and the page must be aborted!</p>
<p><i>nsDialogs::Create</i> 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 <i>SendMessage</i>, <i>SetCtlColors</i> and Win32 API functions.</p>
<p>The dialog is not fully constructed at this point and you can make modifications to it before it is displayed. To finalize and display the dialog you must call <i>nsDialogs::Show</i>. This function will not return until the user clicks Next, Back or Cancel.</p>
</span>


<h3><a name="step-add"></a>Adding Controls</h3>

<span class="inlcod">
<p>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 <a href="#mref-create">${NSD_Create*}</a> 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 <i>HWND</i>. Like the dialogs <i>HWND</i>, it must be popped from the stack and saved.</p>

<p>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 <i>u</i>. To use percentage, the measurement must be suffixed with the percentage sign - <i>%</i>. Any other suffix, or no suffix, means pixels.</p>

<p>Dialog units allow creation of dialogs that scale well when different fonts or <abbr title="Dots per Inch">DPI</abbr> is used. Its size in pixels is determined on runtime based on the font and the DPI. For example, standard pages in the classic NSIS user interface are 266 dialog units wide and 130 dialog units high. Pages in Modern UI are 300 dialogs units wide and 140 dialog units high. In different resolutions, using different fonts or DPI settings, the dialogs will always have the same size in dialog units, but different size in pixels.</p>
</span>
<blockquote><pre><b>!include nsDialogs.nsh</b>
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe
XPStyle on

Var Dialog
<b>Var Label
Var Text</b>

Page custom nsDialogsPage
Page instfiles

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}
<b>
    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
    Pop $Text
</b>
    nsDialogs::Show

FunctionEnd

Section
SectionEnd</pre></blockquote>

<p>Available control types that can be created with <a href="#mref-create">${NSD_Create*}</a> are: 
HLine, 
VLine, 
Label, 
Icon, 
Bitmap, 
BrowseButton, 
Link, 
Button, 
GroupBox, 
CheckBox, 
RadioButton, 
Text, 
Password, 
Number, 
FileRequest, 
DirRequest, 
RichEdit, 
ComboBox, 
DropList, 
ListBox, 
SortedListBox, 
ProgressBar, 
Animation, 
HTrackBar, 
VTrackBar, 
UpDown, 
HotKey,
IPAddress.
</p>

<h3><a name="step-state"></a>Control State</h3>

<span class="inlcod">
<p>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 <a href="#mref-gettext">${NSD_GetText}</a> macro. Use the <a href="#mref-getstate">${NSD_GetState}</a> macro for RadioButton and CheckBox controls.</p>

<p>Note that not all controls support <a href="#mref-gettext">${NSD_GetText}</a> and some require special handling with specific messages defined in WinMessages.nsh. For example, the ListBox control requires usage of <i>LB_GETCURSEL</i> and <i>LB_GETTEXT</i>. With time, the library of macros in nsDialogs.nsh will fill with more and more macros that'll handle more cases like this.</p>
</span>
<blockquote><pre>!include nsDialogs.nsh
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe
XPStyle on

Var Dialog
Var Label
Var Text

Page custom nsDialogsPage <b>nsDialogsPageLeave</b>
Page instfiles

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
    Pop $Text

    nsDialogs::Show

FunctionEnd

<b>Function nsDialogsPageLeave

    ${NSD_GetText} $Text $0
    MessageBox MB_OK "You typed:$\n$\n$0"

FunctionEnd</b>

Section
SectionEnd</pre></blockquote>

<h3><a name="step-notify"></a>Real-time Notification</h3>

<span class="inlcod">
<p>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 <a href="#mref-onclick">${NSD_OnClick}</a> and <a href="#mref-onchange">${NSD_OnChange}</a>. Not every control supports both of the events. For example, there is nothing to notify about label changes, only clicks.</p>

<p>When the callback function is called, the control's <i>HWND</i> 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 <i>HWND</i> can shed some light on which control originated the event.</p>

<p>The new example will respond to the user typing "hello" in the text box.</p>
</span>
<blockquote><pre>!include nsDialogs.nsh
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe
XPStyle on

Var Dialog
Var Label
Var Text

Page custom nsDialogsPage nsDialogsPageLeave
Page instfiles

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
    Pop $Text
    <b>${NSD_OnChange} $Text nsDialogsPageTextChange</b>

    nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

    ${NSD_GetText} $Text $0
    MessageBox MB_OK "You typed:$\n$\n$0"

FunctionEnd

<b>Function nsDialogsPageTextChange

    Pop $1 # $1 == $ Text

    ${NSD_GetText} $Text $0

    ${If} $0 == "hello"

        MessageBox MB_OK "right back at ya!"

    ${EndIf}

FunctionEnd</b>

Section
SectionEnd</pre></blockquote>

<h3><a name="step-memory"></a>Memory</h3>

<p>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 <a href="#mref-getstate">${NSD_GetState}</a> and <a href="#mref-setstate">${NSD_SetState}</a> to get and set its state.</p>

<p>For clarity, we'll remove some of the notifications from the previous step.</p>

<blockquote><pre>!include nsDialogs.nsh
!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe
XPStyle on

Var Dialog
Var Label
Var Text
<b>Var Text_State
Var Checkbox
Var Checkbox_State</b>

Page custom nsDialogsPage nsDialogsPageLeave
<b>Page license</b>
Page instfiles

<b>Function .onInit

    StrCpy $Text_State "Type something here..."

FunctionEnd</b>

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 0 13u 100% <b>12u $Text_State</b>
    Pop $Text

    <b>${NSD_CreateCheckbox} 0 30u 100% 10u "&amp;Something"
    Pop $Checkbox

    ${If} $Checkbox_State == ${BST_CHECKED}
        ${NSD_Check} $Checkbox
    ${EndIf}

    # alternative for the above ${If}:
    #${NSD_SetState} $Checkbox_State</b>

    nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

    ${NSD_GetText} $Text <b>$Text_State</b>
    <b>${NSD_GetState} $Checkbox $Checkbox_State</b>

FunctionEnd

Section
SectionEnd</pre></blockquote>

<h2><a name="ref"></a>Function Reference</h2>

<h3><a name="ref-create"></a>Create</h3>
<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 1044 for the welcome and the finish page.</p>
<p>Returns the new dialog's HWND on the stack or <i>error</i>.</p>

<h3><a name="ref-createcontrol"></a>CreateControl</h3>
<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>
<p>Returns the new control's HWND on the stack or <i>error</i>.</p>

<h3><a name="ref-show"></a>Show</h3>
<p><code>nsDialogs::Show</code></p>
<p>Displays the page. Call this once finished with nsDialogs::Create, nsDialogs::CreateControl and the rest.</p>
<p>Returns nothing.</p>

<h3><a name="ref-selectfiledialog"></a>SelectFileDialog</h3>
<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>
<p><i>initial_selection</i> can be used to provide the user with a default file to look for and/or a default folder to look in. If <i>initial_selection</i> is empty no default filename will be provided for the user and the dialog will start in the current working directory. If <i>initial_selection</i> specifies just a filename, for example "test.exe", the dialog will be set up to look for a file called test.exe in the current working directory. If <i>initial_selection</i> specifies just a directory, for example "C:\Program Files", the dialog starts in the provided directory with no file name provided. If <i>initial_selection</i> specifies a directory and a filename, for example "C:\Windows\System32\calc.exe", the dialog will be set up to look for a file called calc.exe in the directory C:\Windows\System32.</p>
<p>Returns the selected file on the stack or an empty string if the user canceled the operation.</p>

<h3><a name="ref-selectfolderdialog"></a>SelectFolderDialog</h3>
<p><code>nsDialogs::SelectFolderDialog <i>title</i> <i>initial_selection</i></code></p>
<p>Displays a directory selection dialog to the user.</p>
<p>Returns the selected directory on the stack or "error" in case the user canceled the operation or an error occured.</p>

<h3><a name="ref-setrtl"></a>SetRTL</h3>
<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>
<p>Returns nothing.</p>

<h3><a name="ref-getuserdata"></a>GetUserData</h3>
<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 <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>
<p>Returns nothing.</p>

<h3><a name="ref-onback"></a>OnBack</h3>
<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>
<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
<p>Returns nothing.</p>

<h3><a name="ref-onchange"></a>OnChange</h3>
<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>
<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
<p>Returns nothing.</p>

<h3><a name="ref-onclick"></a>OnClick</h3>
<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>
<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
<p>Returns nothing.</p>

<h3><a name="ref-onnotify"></a>OnNotify</h3>
<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 NMHDR structure will be waiting on its stack.</p>
<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
<p>Returns nothing.</p>

<h3><a name="ref-createtimer"></a>CreateTimer</h3>
<p><code>nsDialogs::CreateTimer <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>
<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
<p>Returns nothing.</p>

<h3><a name="ref-killtimer"></a>KillTimer</h3>
<p><code>nsDialogs::KillTimer <i>function_address</i></code></p>
<p>Kills a previously set timer.</p>
<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
<p>Returns nothing.</p>

<h2><a name="mref"></a>Macro Reference</h2>
<p>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.</p>

<h3><a name="mref-create"></a>NSD_Create*</h3>
<p><code>${NSD_Create*} <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>
<p>Available variants:</p>
<ul>
<li>${NSD_CreateHLine}</li>
<li>${NSD_CreateVLine}</li>
<li>${NSD_CreateLabel}</li>
<li>${NSD_CreateIcon}</li>
<li>${NSD_CreateBitmap}</li>
<li>${NSD_CreateBrowseButton}</li>
<li>${NSD_CreateLink}</li>
<li>${NSD_CreateButton}</li>
<li>${NSD_CreateGroupBox}</li>
<li>${NSD_CreateCheckBox}</li>
<li>${NSD_CreateRadioButton}</li>
<li>${NSD_CreateText}</li>
<li>${NSD_CreatePassword}</li>
<li>${NSD_CreateNumber}</li>
<li>${NSD_CreateFileRequest}</li>
<li>${NSD_CreateDirRequest}</li>
<li>${NSD_CreateRichEdit}</li>
<li>${NSD_CreateComboBox}</li>
<li>${NSD_CreateDropList}</li>
<li>${NSD_CreateListBox}</li>
<li>${NSD_CreateSortedListBox}</li>
<li>${NSD_CreateProgressBar}</li>
<li>${NSD_CreateAnimation}</li>
<li>${NSD_CreateHTrackBar}</li>
<li>${NSD_CreateVTrackBar}</li>
<li>${NSD_CreateUpDown}</li>
<li>${NSD_CreateHotKey}</li>
<li>${NSD_CreateIPAddress} <small>(Requires <abbr title="Internet Explorer">IE</abbr>4)</small></li>
</ul>
<p>Returns the new control's HWND on the stack or <i>error</i></p>

<h3><a name="mref-onback"></a>NSD_OnBack</h3>
<p><code>${NSD_OnBack} <i>function_name</i></code></p>
<p>See <a href="#ref-onback">OnBack</a> for more details.</p>

<p></p>

<h3><a name="mref-onchange"></a>NSD_OnChange</h3>
<p><code>${NSD_OnChange} <i>control_HWND</i> <i>function_name</i></code></p>
<p>See <a href="#ref-onchange">OnChange</a> for more details.</p>
<p>See <a href="#step-notify">Real-time Notification</a> for usage example.</p>

<h3><a name="mref-onclick"></a>NSD_OnClick</h3>
<p><code>${NSD_OnClick} <i>control_HWND</i> <i>function_name</i></code></p>
<p>See <a href="#ref-onclick">OnClick</a> for more details.</p>

<h3><a name="mref-onnotify"></a>NSD_OnNotify</h3>
<p><code>${NSD_OnNotify} <i>control_HWND</i> <i>function_name</i></code></p>
<p>See <a href="#ref-onnotify">OnNotify</a> for more details.</p>

<h3><a name="mref-setfocus"></a>NSD_SetFocus</h3>
<p><code>${NSD_SetFocus} <i>control_HWND</i></code></p>
<p>Sets focus to a control.</p>

<h3><a name="mref-createtimer"></a>NSD_CreateTimer</h3>
<p><code>${NSD_CreateTimer} <i>function_name</i> <i>timer_interval</i></code></p>
<p>See <a href="#ref-createtimer">CreateTimer</a> for more details.</p>

<h3><a name="mref-killtimer"></a>NSD_KillTimer</h3>
<p><code>${NSD_KillTimer} <i>function_name</i></code></p>
<p>See <a href="#ref-killtimer">KillTimer</a> for more details.</p>

<h3><a name="mref-addstyle"></a>NSD_AddStyle</h3>
<p><code>${NSD_AddStyle} <i>control_HWND</i> <i>style</i></code></p>
<p>Adds one or more window styles to a control. Multiple styles should be separated with pipes `|'.</p>
<p>See MSDN for shared and per-control style descriptions.</p>

<h3><a name="mref-addexstyle"></a>NSD_AddExStyle</h3>
<p><code>${NSD_AddExStyle} <i>control_HWND</i> <i>style</i></code></p>
<p>Adds one or more extended window styles to a control. Multiple styles should be separated with pipes `|'.</p>
<p>See <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543">MSDN</a> for style descriptions.</p>

<h3><a name="mref-gettext"></a>NSD_GetText</h3>
<p><code>${NSD_GetText} <i>control_HWND</i> <i>$output_variable</i></code></p>
<p>Retrieves the text of a control and stores it into <i>output_variable</i>. Especially useful for textual controls.</p>
<p>See <a href="#step-state">Control State</a> for usage example.</p>

<h3><a name="mref-settext"></a>NSD_SetText</h3>
<p><code>${NSD_SetText} <i>control_HWND</i> <i>text</i></code></p>
<p>Sets the text of a control.</p>

<h3><a name="mref-settextlimit"></a>NSD_Edit_SetTextLimit</h3>
<p><code>${NSD_Edit_SetTextLimit} <i>control_HWND</i> <i>limit</i></code></p>
<p>Sets the input length limit for a text control.</p>

<h3><a name="mref-edsetro"></a>NSD_Edit_SetReadOnly</h3>
<p><code>${NSD_Edit_SetReadOnly} <i>control_HWND</i> <i>readonly</i></code></p>
<p>1 to make the text control read-only or 0 to allow the user to input data.</p>

<h3><a name="mref-edsetcuebanner"></a>NSD_Edit_SetCueBannerText</h3>
<p><code>${NSD_Edit_SetCueBannerText} <i>control_HWND</i> <i>displaywhenfocused</i> <i>text</i></code></p>
<p>Set a text hint displayed when the control is empty. The text is only visible on WinXP and later. Requires <i>XPStyle on</i>.</p>

<h3><a name="mref-richsettextlimit"></a>NSD_RichEd_SetTextLimit</h3>
<p><code>${NSD_RichEd_SetTextLimit} <i>control_HWND</i> <i>limit</i></code></p>
<p>Sets the input length limit.</p>

<h3><a name="mref-richseteventmask"></a>NSD_RichEd_SetEventMask</h3>
<p><code>${NSD_RichEd_SetEventMask} <i>control_HWND</i> <i>eventmask</i></code></p>

<h3><a name="mref-richsetbkclr"></a>NSD_RichEd_SetCustomBackgroundColor</h3>
<p><code>${NSD_RichEd_SetCustomBackgroundColor} <i>control_HWND</i> <i>COLORREF</i></code></p>

<h3><a name="mref-getstate"></a>NSD_GetState</h3>
<p><code>${NSD_GetState} <i>control_HWND</i> <i>$output_variable</i></code></p>
<p>Retrieves the state of a check box or a radio button control. Possible outputs are ${BST_CHECKED} and ${BST_UNCHECKED}.</p>
<p>See <a href="#step-memory">Memory</a> for usage example.</p>

<h3><a name="mref-setstate"></a>NSD_SetState</h3>
<p><code>${NSD_SetState} <i>control_HWND</i> <i>state</i></code></p>
<p>Sets the state of a check box or a radio button control. Possible values for <i>state</i> are ${BST_CHECKED} and ${BST_UNCHECKED}.</p>
<p>See <a href="#step-memory">Memory</a> for usage example.</p>

<h3><a name="mref-check"></a>NSD_Check</h3>
<p><code>${NSD_Check} <i>control_HWND</i></code></p>
<p>Checks a check box or a radio button control. Same as calling ${NSD_SetState} with ${BST_CHECKED}.</p>

<h3><a name="mref-uncheck"></a>NSD_Uncheck</h3>
<p><code>${NSD_Uncheck} <i>control_HWND</i></code></p>
<p>Unchecks a check box or a radio button control. Same as calling ${NSD_SetState} with ${BST_UNCHECKED}.</p>
<p>See <a href="#step-memory">Memory</a> for usage example.</p>

<h3><a name="mref-cbaddstring"></a>NSD_CB_AddString</h3>
<p><code>${NSD_CB_AddString} <i>combo_HWND</i> <i>string</i></code></p>
<p>Adds a string to a combo box.</p>

<h3><a name="mref-cbinsstring"></a>NSD_CB_InsertString</h3>
<p><code>${NSD_CB_InsertString} <i>combo_HWND</i> <i>index</i> <i>string</i></code></p>
<p><code>${NSD_CB_PrependString} <i>combo_HWND</i> <i>string</i></code></p>
<p><code>${NSD_CB_AppendString} <i>combo_HWND</i> <i>string</i></code></p>
<p>Insert a string in a specified position in a combo box.</p>

<h3><a name="mref-cbselectstring"></a>NSD_CB_SelectString</h3>
<p><code>${NSD_CB_SelectString} <i>combo_HWND</i> <i>string</i></code></p>
<p>Selects a string in a combo box.</p>

<h3><a name="mref-cbgetcount">NSD_CB_GetCount</a></h3>
<p><code>${NSD_CB_GetCount} <i>combo_HWND</i> <i>$output_variable</i></code></p>

<h3><a name="mref-lbaddstring"></a>NSD_LB_AddString</h3>
<p><code>${NSD_LB_AddString} <i>listbox_HWND</i> <i>string</i></code></p>
<p>Adds a string to a list box.</p>

<h3><a name="mref-lbinsstring"></a>NSD_LB_InsertString</h3>
<p><code>${NSD_LB_InsertString} <i>listbox_HWND</i> <i>index</i> <i>string</i></code></p>
<p><code>${NSD_LB_PrependString} <i>listbox_HWND</i> <i>string</i></code></p>
<p><code>${NSD_LB_AppendString} <i>listbox_HWND</i> <i>string</i></code></p>
<p>Insert a string in a specified position in a list box.</p>

<h3><a name="mref-lbdelstring"></a>NSD_LB_DelString</h3>
<p><code>${NSD_LB_DelString} <i>listbox_HWND</i> <i>string</i></code></p>
<p>Deletes a string from a list box.</p>

<h3><a name="mref-lbdelitem"></a>NSD_LB_DelItem</h3>
<p><code>${NSD_LB_DelItem} <i>listbox_HWND</i> <i>itemindex</i></code></p>
<p>Deletes a string from a list box.</p>

<h3><a name="mref-lbclear">NSD_LB_Clear</a></h3>
<p><code>${NSD_LB_Clear} <i>listbox_HWND</i></code></p>
<p>Deletes all strings from a list box.</p>

<h3><a name="mref-lbgetcount">NSD_LB_GetCount</a></h3>
<p><code>${NSD_LB_GetCount} <i>listbox_HWND</i> <i>$output_variable</i></code></p>
<p>Retrieves the number of strings from a list box.</p>

<h3><a name="mref-lbselectstring"></a>NSD_LB_SelectString</h3>
<p><code>${NSD_LB_SelectString} <i>listbox_HWND</i> <i>string</i></code></p>
<p>Selects a string in a list box.</p>

<h3><a name="mref-lbgetselection">NSD_LB_GetSelection</a></h3>
<p><code>${NSD_LB_GetSelection} <i>listbox_HWND</i> <i>$output_variable</i></code></p>
<p>Retrieves the selected stringed from a list box. Returns an empty string if no string is selected.</p>

<h3><a name="mref-animopenfile">NSD_Anim_OpenFile</a></h3>
<p><code>${NSD_Anim_OpenFile} <i>anim_HWND</i> <i>avi_path</i></code></p>
<p>Opens the specified (silent) .AVI movie clip.</p>

<h3><a name="mref-animplay">NSD_Anim_Play</a></h3>
<p><code>${NSD_Anim_Play} <i>anim_HWND</i></code></p>
<p>Plays the movie clip repeatedly.</p>

<h3><a name="mref-animstop">NSD_Anim_Stop</a></h3>
<p><code>${NSD_Anim_Stop} <i>anim_HWND</i></code></p>
<p>Stops playback.</p>

<h3><a name="mref-trackgetpos">NSD_TrackBar_GetPos</a></h3>
<p><code>${NSD_TrackBar_GetPos} <i>track_HWND</i> <i>$output</i></code></p>

<h3><a name="mref-tracksetpos">NSD_TrackBar_SetPos</a></h3>
<p><code>${NSD_TrackBar_SetPos} <i>track_HWND</i> <i>pos</i></code></p>

<h3><a name="mref-tracksetrmin">NSD_TrackBar_SetRangeMin</a></h3>
<p><code>${NSD_TrackBar_SetRangeMin} <i>track_HWND</i> <i>minpos</i></code></p>

<h3><a name="mref-tracksetrmax">NSD_TrackBar_SetRangeMax</a></h3>
<p><code>${NSD_TrackBar_SetRangeMax} <i>track_HWND</i> <i>maxpos</i></code></p>

<h3><a name="mref-tracksetticfr">NSD_TrackBar_SetTicFreq</a></h3>
<p><code>${NSD_TrackBar_SetTicFreq} <i>track_HWND</i> <i>frequency</i></code></p>
<p>Sets the interval frequency for tick marks.</p>

<h3><a name="mref-udsetbuddy">NSD_UD_SetBuddy</a></h3>
<p><code>${NSD_UD_SetBuddy} <i>ud_HWND</i> <i>buddy_HWND</i></code></p>

<h3><a name="mref-udgetpos">NSD_UD_GetPos</a></h3>
<p><code>${NSD_UD_GetPos} <i>ud_HWND</i> <i>$output</i></code></p>

<h3><a name="mref-udsetpos">NSD_UD_SetPos</a></h3>
<p><code>${NSD_UD_SetPos} <i>ud_HWND</i> <i>pos</i></code></p>

<h3><a name="mref-udsetpackedrange">NSD_UD_SetPackedRange</a></h3>
<p><code>${NSD_UD_SetPackedRange} <i>ud_HWND</i> <i>packedrange</i></code></p>
<p>Sets the min-max range. Two signed 16-bit numbers packed into 32-bits.</p>

<h3><a name="mref-hkgethk">NSD_HK_GetHotKey</a></h3>
<p><code>${NSD_HK_GetHotKey} <i>hk_HWND</i> <i>$output</i></code></p>
<p>Bits 0..7 specify the virtual key code and bits 8..15 specify the HOTKEYF modifier flags.</p>

<h3><a name="mref-hksethk">NSD_HK_SetHotKey</a></h3>
<p><code>${NSD_HK_SetHotKey} <i>hk_HWND</i> <i>packedhotkey</i></code></p>

<h3><a name="mref-setimage"></a>NSD_SetImage</h3>
<p><code>${NSD_SetImage} <i>control_HWND</i> <i>image_path</i> <i>$output_variable</i></code></p>
<p>Loads a bitmap from <i>image_path</i> and displays it on <i>control_HWND</i> created by <a href="#mref-create">${NSD_CreateBitmap}</a>. The image handle is stored in <i>output_variable</i> and should be freed using <a href="#mref-freeimage">${NSD_FreeImage}</a> once no longer necessary.</p>
<p>The image must be extracted to the user's computer prior to calling this macro. A good place to extract images is $PLUGINSDIR.</p>
<blockquote><pre>!include nsDialogs.nsh

Name nsDialogs
OutFile nsDialogs.exe

Page custom nsDialogsImage
Page instfiles

Var Dialog
Var Image
Var ImageHandle

Function .onInit
    InitPluginsDir
    File /oname=$PLUGINSDIR\image.bmp "${NSISDIR}\Contrib\Graphics\Header\nsis-r.bmp"
FunctionEnd

Function nsDialogsImage
    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateBitmap} 0 0 100% 100% ""
    Pop $Image
    ${NSD_SetImage} $Image $PLUGINSDIR\image.bmp $ImageHandle

    nsDialogs::Show

    ${NSD_FreeImage} $ImageHandle
FunctionEnd

Section
SectionEnd</pre></blockquote>

<h3><a name="mref-setsimage"></a>NSD_SetStretchedImage</h3>
<p><code>${NSD_SetStretchedImage} <i>control_HWND</i> <i>image_path</i> <i>$output_variable</i></code></p>
<p>Loads and displays a bitmap just like <a href="#mref-setimage">${NSD_SetImage}</a>, but stretched the image to fit the control.</p>

<h3><a name="mref-clearimage"></a>NSD_ClearImage</h3>
<p><code>${NSD_ClearImage} <i>control_HWND</i></code></p>
<p>Clears an image from a control.</p>

<h3><a name="mref-freeimage"></a>NSD_FreeImage</h3>
<p><code>${NSD_FreeImage} <i>image_handle</i></code></p>
<p>Frees an image handle previously loaded with <a href="#mref-setimage">${NSD_SetImage}</a> or <a href="#mref-setsimage">${NSD_SetStretchedImage}</a>.</p>

<h3><a name="mref-seticon"></a>NSD_SetIcon</h3>
<p><code>${NSD_SetIcon} <i>control_HWND</i> <i>image_path</i> <i>$output_variable</i></code></p>
<p>Same as <a href="#mref-setimage">${NSD_SetImage}</a>, but used for loading and setting an icon in a control created by <a href="#mref-create">${NSD_CreateIcon}</a>. The image handle is stored in <i>output_variable</i> and should be freed using <a href="#mref-freeicon">${NSD_FreeIcon}</a> once no longer necessary.</p>

<h3><a name="mref-seticonfrominstaller"></a>NSD_SetIconFromInstaller</h3>
<p><code>${NSD_SetIconFromInstaller} <i>control_HWND</i> <i>$output_variable</i></code></p>
<p>Loads the icon used in the installer and displays it on <i>control_HWND</i> created by <a href="#mref-create">${NSD_CreateIcon}</a>. The image handle is stored in <i>output_variable</i> and should be freed using <a href="#mref-freeicon">${NSD_FreeIcon}</a> once no longer necessary.</p>

<h3><a name="mref-clearicon"></a>NSD_ClearIcon</h3>
<p><code>${NSD_ClearIcon} <i>control_HWND</i></code></p>
<p>Clears an icon from a control.</p>

<h3><a name="mref-freeicon"></a>NSD_FreeIcon</h3>
<p><code>${NSD_FreeIcon} <i>icon_handle</i></code></p>
<p>Frees an icon handle previously loaded with <a href="#mref-seticon">${NSD_SetIcon}</a> or <a href="#mref-seticonfrominstaller">${NSD_SetIconFromInstaller}</a>.</p>


<h2><a name="faq"></a>FAQ</h2>

<div>

<ul>

<li>
<b>Q:</b> Can nsDialogs handle InstallOptions INI files?
<blockquote>
<p><b>A:</b> nsDialogs.nsh contains a function called <i>CreateDialogFromINI</i> that can create nsDialogs' dialog from an INI file. It can handle every type of control InstallOptions supports, but doesn't handle the flags or notifications. <i>Examples\nsDialogs\InstallOptions.nsi</i> shows a usage example of this function.</p>
</blockquote>
</li>

</ul>

</div>

</body>
</html>