nsis64 / Contrib / nsDialogs / Readme.html

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
<!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">
b
{
	color: red;
}
code
{
	margin-left: 20px;
	padding: 7px;
	background-color: rgb(240,240,240);
}
</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-basic">Basic Script</a></li>
<li><a href="#step-page">Custom Page</a></li>
<li><a href="#step-create">Creating Page</a></li>
<li><a href="#step-show">Showing 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></li>
<li><a href="#mref-onchange">NSD_OnChange</a></li>
<li><a href="#mref-onclick">NSD_OnClick</a></li>
<li><a href="#mref-onnotify">NSD_OnNotify</a></li>
<li><a href="#mref-createtimer">NSD_CreateTimer</a></li>
<li><a href="#mref-killtimer">NSD_KillTimer</a></li>
<li><a href="#mref-addstyle">NSD_AddStyle</a></li>
<li><a href="#mref-addexstyle">NSD_AddExStyle</a></li>
<li><a href="#mref-gettext">NSD_GetText</a></li>
<li><a href="#mref-settext">NSD_SetText</a></li>
<li><a href="#mref-settextlimit">NSD_SetTextLimit</a></li>
<li><a href="#mref-getstate">NSD_GetState</a></li>
<li><a href="#mref-setstate">NSD_SetState</a></li>
<li><a href="#mref-check">NSD_Check</a></li>
<li><a href="#mref-uncheck">NSD_Uncheck</a></li>
<li><a href="#mref-cbaddstring">NSD_CB_AddString</a></li>
<li><a href="#mref-cbselectstring">NSD_CB_SelectString</a></li>
<li><a href="#mref-lbaddstring">NSD_LB_AddString</a></li>
<li><a href="#mref-lbdelstring">NSD_LB_DelString</a></li>
<li><a href="#mref-lbclear">NSD_LB_Clear</a></li>
<li><a href="#mref-lbgetcount">NSD_LB_GetCount</a></li>
<li><a href="#mref-lbselectstring">NSD_LB_SelectString</a></li>
<li><a href="#mref-lbgetselection">NSD_LB_GetSelection</a></li>
<li><a href="#mref-setfocus">NSD_SetFocus</a></li>
<li><a href="#mref-setimage">NSD_SetImage</a></li>
<li><a href="#mref-setsimage">NSD_SetStretchedImage</a></li>
<li><a href="#mref-seticon">NSD_SetIcon</a></li>
<li><a href="#mref-seticonfrominstaller">NSD_SetIconFromInstaller</a></li>
<li><a href="#mref-clearimage">NSD_ClearImage</a></li>
<li><a href="#mref-clearicon">NSD_ClearIcon</a></li>
<li><a href="#mref-freeimage">NSD_FreeImage</a></li>
<li><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 new 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 core functionality by modifying the library or simply avoid using it.</p>

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

<h3><a name="step-basic"></a>Basic Script</h3>

<p>Before using nsDialogs, lets first create a basic script as our skeleton.</p>

<blockquote><pre>Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Page instfiles

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

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

<p>Next, we'll add a custom page where we can use nsDialogs. nsDialogs cannot be used in sections or any other function but a custom page's function.</p>

<blockquote><pre>Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

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

<b>Function nsDialogsPage
FunctionEnd</b>

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-create"></a>Creating Page</h3>

<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 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>

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

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

<b>Var Dialog</b>

Page custom nsDialogsPage
Page instfiles

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

	${If} $Dialog == error
		Abort
	${EndIf}
</b>
FunctionEnd

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<h3><a name="step-show"></a>Showing Page</h3>

<p>Now that the page is created, it's time to show it. This is done with nsDialogs::Show. This function will not return until the user clicks Next, Back or Cancel.</p>

<blockquote><pre>!include LogicLib.nsh

Name nsDialogs
OutFile nsDialogs.exe

XPStyle on

Var Dialog

Page custom nsDialogsPage
Page instfiles

Function nsDialogsPage
	nsDialogs::Create 1018
	Pop $Dialog

	${If} $Dialog == error
		Abort
	${EndIf}
<b>
	nsDialogs::Show
</b>
FunctionEnd

Section

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

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

<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 HWND. Like the dialogs HWND, 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 DPI 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>

<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

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

<p>Available control types that can be created with <a href="#mref-create">${NSD_Create*}</a> are:</p>

<ul>
<li>HLine</li>
<li>VLine</li>
<li>Label</li>
<li>Icon</li>
<li>Bitmap</li>
<li>BrowseButton</li>
<li>Link</li>
<li>Button</li>
<li>GroupBox</li>
<li>CheckBox</li>
<li>RadioButton</li>
<li>Text</li>
<li>Password</li>
<li>Number</li>
<li>FileRequest</li>
<li>DirRequest</li>
<li>ComboBox</li>
<li>DropList</li>
<li>ListBox</li>
<li>ProgressBar</li>
</ul>

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

<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 <i>leave callback</i> 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>

<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

	DetailPrint "hello world"

SectionEnd</pre></blockquote>

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

<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 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.</p>

<p>The new example will respond to the user type <i>hello</i> in the text box.</p>

<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

	DetailPrint "hello world"

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

	DetailPrint "hello world"

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 1040 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 dialog'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 MNHDR 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_CreateComboBox}</li>
<li>${NSD_CreateDropList}</li>
<li>${NSD_CreateListBox}</li>
<li>${NSD_CreateProgressBar}</li>
</ul>

<p>Returns the new dialog's HWND on the stack or error.</p>

<h3><a name="mref-onback"></a>NSD_OnBack</h3>

<p><code>${NSD_OnBack} <i>function_address</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_address</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_address</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_address</i></code></p>

<p>See <a href="#ref-onnotify">OnNotify</a> for more details.</p>

<h3><a name="mref-createtimer"></a>NSD_CreateTimer</h3>

<p><code>${NSD_CreateTimer} <i>function_address</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_address</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 style to a control. Multiple styles should be separated with pipes `|'.</p>

<p>See MSDN for style description.</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 style to a control. Multiple styles should be separated with pipes `|'.</p>

<p>See MSDN for style description.</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_SetTextLimit</h3>

<p><code>${NSD_SetTextLimit} <i>control_HWND</i> <i>limit</i></code></p>

<p>Sets input size limit for a text control.</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-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-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-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-lbcleqar">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-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-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

XPStyle on

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-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 isntaller 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-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-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-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-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 notification yet. <i>Examples\nsDialogs\InstallOptions.nsi</i> shows a usage example of this function.</p><p>In the future there'll also be a function that creates the script itself.
</blockquote>
</li>

</ul>

</div>

</body>
</html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.