~~Title: Script Dialog Example ~~ This is an example of a [[..:script_dialogs|script dialog]]; it implements the dialog shown at the start of the [[..:script_dialogs|Script Dialogs]] section. It makes use of a //Tab control// to host two child dialogs, and also demonstrates how to add and remove strings from a //List Box// control. {{:media:image057.png?nolink|}} The //Tab control// has been configured to host two child dialogs; //Interests// and //Favorite Books//. Clicking the tabs lets you switch back and forth between the two pages. Most of the dialog’s controls don’t actually do anything – only the //Favorite Books// tab has been implemented. If you switch to that tab you can enter a string in the //Enter title// field and click the **Add** button to add it to the list. Click an item in the list and click the **Delete** button to remove it. This dialog also provides an example of a resizable dialog. You can make any dialog resizable, but it’s particularly useful when working with tabs, as it means the //Tab control// and the parent dialog can automatically size to fit the content displayed inside the tabs. If you want to experiment with this example, create a new toolbar button (with the type to //Script Function//) and paste the script code into the **Script Code** tab of the command editor, and the resources XML into the **Resources** tab. All the following examples are written in VBScript. ==Code== Function OnClick(ByRef clickData) Set dlg = DOpus.Dlg dlg.window = clickData.func.sourcetab dlg.template = "person" dlg.detach = true dlg.Show Do Set msg = dlg.GetMsg() Select Case msg.control Case "add" ' get the string the user has entered str = dlg.Control("title", "books").value if Len(str) > 0 Then ' add to the list box and clear the edit field dlg.Control("books", "books").AddItem(str) dlg.Control("title", "books").value = "" End If Case "del" ' get the selection from the list box sel = dlg.Control("books", "books").value if sel > -1 Then ' remove it from the list dlg.Control("books", "books").RemoveItem(sel) End If End Select Loop While msg End Function ==Resources==