home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 May / CHIPCD200305.iso / super / openofficecn / f_0047 / sbasic.jar / text / sbasic / guide / sample_code.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-02-21  |  8.3 KB  |  102 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Program Examples for Controls in the Dialog Editor</title><meta name="filename" content="text/sbasic/guide/sample_code"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         table.Tabelle1{
  5.                 }
  6.         span.Tabelle1A{
  7.                 width:2.461cm;}
  8.         span.Tabelle1B{
  9.                 width:15.538cm;}
  10.         td.Tabelle1A1{
  11.                 }
  12.         p.P1{
  13.                 }
  14.         p.P2{
  15.                 }
  16.         span.T1{
  17.                 font-weight:bold;}
  18.         span.fr1{
  19.                 }
  20.         </style></head><body>
  21.    
  22.    
  23.    <p class="P1"/>
  24.    <p class="Head1"><help:key-word value="program examples for controls; dialog editor" tag="kw68535_1" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="sample_code" xmlns:help="http://openoffice.org/2000/help"><help:link Id="68535">Program Examples for Controls in the Dialog Editor</help:link></help:to-be-embedded></p>
  25.    <p class="Paragraph">For these examples, create a new <help:link Id="68530" xmlns:help="http://openoffice.org/2000/help">dialog</help:link> with the name <span class="T1">Dialog1</span>. In the dialog editor, create the following controls: a <span class="T1">check box</span> with the name <span class="T1">CheckBox1</span>, a <span class="T1">label field</span> with the name <span class="T1">Label1</span>, a <span class="T1">button</span> with the name <span class="T1">CommandButton1</span>, and a <span class="T1">list box</span> with the name <span class="T1">ListBox1</span>.</p>
  26.    <table><tr class=""><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  27.        <p class="TextInTable"><draw:image draw:style-name="fr1" draw:name="HIND_5" text:anchor-type="paragraph" svg:width="0.847cm" svg:height="0.847cm" draw:z-index="0" xlink:href="65640" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" draw:filter-name="GIF - Graphics Interchange" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:text="http://openoffice.org/2000/text" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
  28.       </span></th><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1B">
  29.        <p class="TextInTable">Use consistent writing (upper/lower case) when you attach a control to an object variable.</p>
  30.       </span></th></tr></table>
  31.    <p class="Head3"><a name="dialogload"/><help:key-word value="example; load a dialog" tag="kw68535_6" xmlns:help="http://openoffice.org/2000/help"/>Global Function for Loading Dialogs</p>
  32.    <p class="PropText">Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)</p>
  33.    <p class="PropText">Dim oLib as Object</p>
  34.    <p class="PropText">Dim oLibDialog as Object</p>
  35.    <p class="PropText">Dim oRuntimeDialog as Object</p>
  36.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>If IsMissing(oLibContainer ) then</p>
  37.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLibContainer = DialogLibraries</p>
  38.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>End If</p>
  39.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLibContainer.LoadLibrary(LibName)</p>
  40.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLib = oLibContainer.GetByName(Libname)</p>
  41.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLibDialog = oLib.GetByName(DialogName)</p>
  42.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oRuntimeDialog = CreateUnoDialog(oLibDialog)</p>
  43.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>LoadDialog() = oRuntimeDialog</p>
  44.    <p class="PropText">End Function</p>
  45.    <p class="Head3"><help:key-word value="example; display a dialog" tag="kw68535_5" xmlns:help="http://openoffice.org/2000/help"/>Display a Dialog</p>
  46.    <p class="PropText">rem global definition of variables</p>
  47.    <p class="PropText">Dim oDialog1 AS Object</p>
  48.    <p class="PropText"/>
  49.    <p class="PropText">Sub StartDialog1</p>
  50.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  51.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1.Execute()</p>
  52.    <p class="PropText">end sub</p>
  53.    <p class="Head3"><help:key-word value="example; read or edit properties of controls" tag="kw68535_4" xmlns:help="http://openoffice.org/2000/help"/>Read or Edit Properties of Controls in the Program</p>
  54.    <p class="PropText">Sub Sample1</p>
  55.    <p class="PropText">oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  56.    <p class="PropText">REM get dialog model</p>
  57.    <p class="PropText">oDialog1Model = oDialog1.Model</p>
  58.    <p class="PropText">REM display text of Label1</p>
  59.    <p class="PropText">oLabel1 = oDialog1.GetControl("Label1")</p>
  60.    <p class="PropText">MsgBox oLabel1.Text</p>
  61.    <p class="PropText">REM set new text for control Label1</p>
  62.    <p class="PropText">oLabel1.Text = "New Files"</p>
  63.    <p class="PropText">REM display model properties for the control CheckBox1</p>
  64.    <p class="PropText">oCheckBox1Model = oDialog1Model.CheckBox1</p>
  65.    <p class="PropText">MsgBox oCheckBox1Model.Dbg_Properties</p>
  66.    <p class="PropText">REM set new state for CheckBox1 for model of control</p>
  67.    <p class="PropText">oCheckBox1Model.State = 1</p>
  68.    <p class="PropText">REM display model properties for control CommandButton1</p>
  69.    <p class="PropText">oCMD1Model = oDialog1Model.CommandButton1</p>
  70.    <p class="PropText">MsgBox oCMD1Model.Dbg_Properties</p>
  71.    <p class="PropText">REM display properties of control CommandButton1</p>
  72.    <p class="PropText">oCMD1 = oDialog1.GetControl("CommandButton1")</p>
  73.    <p class="PropText">MsgBox oCMD1.Dbg_Properties</p>
  74.    <p class="PropText">REM execute dialog</p>
  75.    <p class="PropText">oDialog1.Execute()</p>
  76.    <p class="PropText">End Sub</p>
  77.    <p class="PropText"/>
  78.    <p class="Head3"><help:key-word value="example; add entry to ListBox" tag="kw68535_3" xmlns:help="http://openoffice.org/2000/help"/>Add an Entry to a ListBox</p>
  79.    <p class="PropText">Sub AddEntry</p>
  80.    <p class="PropText">oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  81.    <p class="PropText">REM adds a new entry to the ListBox</p>
  82.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1Model = oDialog1.Model</p>
  83.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListBox = oDialog1.GetControl("ListBox1")</p>
  84.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>dim iCount as integer</p>
  85.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>iCount = oListbox.ItemCount</p>
  86.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListbox.additem("New Item" & iCount,0)</p>
  87.    <p class="PropText">end sub</p>
  88.    <p class="Head3"><help:key-word value="example; remove entry from ListBox" tag="kw68535_2" xmlns:help="http://openoffice.org/2000/help"/>Remove an Entry from a ListBox</p>
  89.    <p class="PropText">Sub RemoveEntry</p>
  90.    <p class="PropText">oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  91.    <p class="PropText">REM remove the first entry from the ListBox</p>
  92.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1Model = oDialog1.Model</p>
  93.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListBox = oDialog1.GetControl("ListBox1")</p>
  94.    <p class="PropText"><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListbox.removeitems(0,1)</p>
  95.    <p class="PropText">end sub</p>
  96.    <p class="P2">Related Topics</p>
  97.    <p class="ParaList"><help:embedded Id="68536" Eid="control_properties" xmlns:help="http://openoffice.org/2000/help"/></p>
  98.    <p class="ParaList"><help:embedded Id="68530" Eid="create_dialog" xmlns:help="http://openoffice.org/2000/help"/></p>
  99.    <p class="ParaList"><help:embedded Id="68537" Eid="insert_control" xmlns:help="http://openoffice.org/2000/help"/></p>
  100.    <p class="ParaList"><help:embedded Id="68538" Eid="show_dialog" xmlns:help="http://openoffice.org/2000/help"/></p>
  101.    <p class="ParaList"/>
  102.   </body></html>