home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / ooo / f_0020 / sbasic.jar / text / sbasic / guide / sample_code.xml < prev    next >
Encoding:
Extensible Markup Language  |  2003-08-01  |  14.8 KB  |  102 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Programming Examples for Controls in the Dialog Editor</title><meta name="filename" content="text/sbasic/guide/sample_code"/><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:0.979cm;}
  8.         span.Tabelle1B{
  9.                 width:17.02cm;}
  10.         td.Tabelle1A1{
  11.                 }
  12.         p.P1{
  13.                 }
  14.         span.T1{
  15.                 font-weight:bold;}
  16.         span.fr1{
  17.                 }
  18.         </style></head><body>
  19.   
  20.   
  21.   <p class="P1"/>
  22.   <p class="Head1"><help:paragraphinfo state="U" number="1" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="programming examples; controls in 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">Programming Examples for Controls in the Dialog Editor</help:link></help:to-be-embedded></p>
  23.   <p class="Paragraph"><help:paragraphinfo state="U" number="2" xmlns:help="http://openoffice.org/2000/help"/>The following examples are for a new <help:link Id="68530" xmlns:help="http://openoffice.org/2000/help">dialog</help:link> called "Dialog1". Use the tools on the <span class="T1">Control </span>floating toolbar in the dialog editor to create the dialog and add the following controls: a <span class="T1">Check Box</span> called "CheckBox1", a <span class="T1">Label Field</span> called "Label1", a <span class="T1">Button</span> called "CommandButton1", and a <span class="T1">List Box</span> called "ListBox1".</p>
  24.   <table><tr class=""><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  25.       <p class="TextInTable"><draw:image draw:name="Icon0" svg:desc="This icon marks text containing important information on data and system security." svg:pixelx="32" svg:pixely="32" svg:width="0.847cm" svg:height="0.847cm" xlink:href="65640" draw:filter-name="" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
  26.  
  27.      </span></th><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1B">
  28.       <p class="TextInTable"><help:paragraphinfo state="U" number="3" xmlns:help="http://openoffice.org/2000/help"/>Be consistent with uppercase and lowercase letter when you attach a control to an object variable.</p>
  29.      </span></th></tr></table>
  30.   <p class="Head3"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/><a name="dialogload"/><help:key-word value="examples; loading a dialog" tag="kw68535_6" xmlns:help="http://openoffice.org/2000/help"/>Global Function for Loading Dialogs</p>
  31.   <p class="PropText"><help:paragraphinfo state="U" number="73" xmlns:help="http://openoffice.org/2000/help"/>Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)</p>
  32.   <p class="PropText"><help:paragraphinfo state="U" number="74" xmlns:help="http://openoffice.org/2000/help"/>Dim oLib as Object</p>
  33.   <p class="PropText"><help:paragraphinfo state="U" number="75" xmlns:help="http://openoffice.org/2000/help"/>Dim oLibDialog as Object</p>
  34.   <p class="PropText"><help:paragraphinfo state="U" number="76" xmlns:help="http://openoffice.org/2000/help"/>Dim oRuntimeDialog as Object</p>
  35.   <p class="PropText"><help:paragraphinfo state="U" number="77" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>If IsMissing(oLibContainer ) then</p>
  36.   <p class="PropText"><help:paragraphinfo state="U" number="78" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLibContainer = DialogLibraries</p>
  37.   <p class="PropText"><help:paragraphinfo state="U" number="79" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>End If</p>
  38.   <p class="PropText"><help:paragraphinfo state="U" number="80" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLibContainer.LoadLibrary(LibName)</p>
  39.   <p class="PropText"><help:paragraphinfo state="U" number="81" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLib = oLibContainer.GetByName(Libname)</p>
  40.   <p class="PropText"><help:paragraphinfo state="U" number="82" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oLibDialog = oLib.GetByName(DialogName)</p>
  41.   <p class="PropText"><help:paragraphinfo state="U" number="83" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oRuntimeDialog = CreateUnoDialog(oLibDialog)</p>
  42.   <p class="PropText"><help:paragraphinfo state="U" number="84" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>LoadDialog() = oRuntimeDialog</p>
  43.   <p class="PropText"><help:paragraphinfo state="U" number="85" xmlns:help="http://openoffice.org/2000/help"/>End Function</p>
  44.   <p class="Head3"><help:paragraphinfo state="U" number="18" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="examples; displaying a dialog" tag="kw68535_5" xmlns:help="http://openoffice.org/2000/help"/>Displaying a Dialog</p>
  45.   <p class="PropText"><help:paragraphinfo state="U" number="86" xmlns:help="http://openoffice.org/2000/help"/>rem global definition of variables</p>
  46.   <p class="PropText"><help:paragraphinfo state="U" number="87" xmlns:help="http://openoffice.org/2000/help"/>Dim oDialog1 AS Object</p>
  47.   <p class="PropText"><help:paragraphinfo state="U" number="88" xmlns:help="http://openoffice.org/2000/help"/>Sub StartDialog1</p>
  48.   <p class="PropText"><help:paragraphinfo state="U" number="162" xmlns:help="http://openoffice.org/2000/help"/>BasicLibraries.LoadLibrary("Tools")</p>
  49.   <p class="PropText"><help:paragraphinfo state="U" number="89" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  50.   <p class="PropText"><help:paragraphinfo state="U" number="92" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1.Execute()</p>
  51.   <p class="PropText"><help:paragraphinfo state="U" number="93" xmlns:help="http://openoffice.org/2000/help"/>end sub</p>
  52.   <p class="Head3"><help:paragraphinfo state="U" number="27" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="examples; 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>
  53.   <p class="PropText"><help:paragraphinfo state="U" number="136" xmlns:help="http://openoffice.org/2000/help"/>Sub Sample1</p>
  54.   <p class="PropText"><help:paragraphinfo state="U" number="163" xmlns:help="http://openoffice.org/2000/help"/>BasicLibraries.LoadLibrary("Tools")</p>
  55.   <p class="PropText"><help:paragraphinfo state="U" number="137" xmlns:help="http://openoffice.org/2000/help"/>oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  56.   <p class="PropText"><help:paragraphinfo state="U" number="138" xmlns:help="http://openoffice.org/2000/help"/>REM get dialog model</p>
  57.   <p class="PropText"><help:paragraphinfo state="U" number="139" xmlns:help="http://openoffice.org/2000/help"/>oDialog1Model = oDialog1.Model</p>
  58.   <p class="PropText"><help:paragraphinfo state="U" number="140" xmlns:help="http://openoffice.org/2000/help"/>REM display text of Label1</p>
  59.   <p class="PropText"><help:paragraphinfo state="U" number="141" xmlns:help="http://openoffice.org/2000/help"/>oLabel1 = oDialog1.GetControl("Label1")</p>
  60.   <p class="PropText"><help:paragraphinfo state="U" number="142" xmlns:help="http://openoffice.org/2000/help"/>MsgBox oLabel1.Text</p>
  61.   <p class="PropText"><help:paragraphinfo state="U" number="143" xmlns:help="http://openoffice.org/2000/help"/>REM set new text for control Label1</p>
  62.   <p class="PropText"><help:paragraphinfo state="U" number="144" xmlns:help="http://openoffice.org/2000/help"/>oLabel1.Text = "New Files"</p>
  63.   <p class="PropText"><help:paragraphinfo state="U" number="145" xmlns:help="http://openoffice.org/2000/help"/>REM display model properties for the control CheckBox1</p>
  64.   <p class="PropText"><help:paragraphinfo state="U" number="146" xmlns:help="http://openoffice.org/2000/help"/>oCheckBox1Model = oDialog1Model.CheckBox1</p>
  65.   <p class="PropText"><help:paragraphinfo state="U" number="147" xmlns:help="http://openoffice.org/2000/help"/>MsgBox oCheckBox1Model.Dbg_Properties</p>
  66.   <p class="PropText"><help:paragraphinfo state="U" number="148" xmlns:help="http://openoffice.org/2000/help"/>REM set new state for CheckBox1 for model of control</p>
  67.   <p class="PropText"><help:paragraphinfo state="U" number="149" xmlns:help="http://openoffice.org/2000/help"/>oCheckBox1Model.State = 1</p>
  68.   <p class="PropText"><help:paragraphinfo state="U" number="150" xmlns:help="http://openoffice.org/2000/help"/>REM display model properties for control CommandButton1</p>
  69.   <p class="PropText"><help:paragraphinfo state="U" number="151" xmlns:help="http://openoffice.org/2000/help"/>oCMD1Model = oDialog1Model.CommandButton1</p>
  70.   <p class="PropText"><help:paragraphinfo state="U" number="152" xmlns:help="http://openoffice.org/2000/help"/>MsgBox oCMD1Model.Dbg_Properties</p>
  71.   <p class="PropText"><help:paragraphinfo state="U" number="153" xmlns:help="http://openoffice.org/2000/help"/>REM display properties of control CommandButton1</p>
  72.   <p class="PropText"><help:paragraphinfo state="U" number="154" xmlns:help="http://openoffice.org/2000/help"/>oCMD1 = oDialog1.GetControl("CommandButton1")</p>
  73.   <p class="PropText"><help:paragraphinfo state="U" number="155" xmlns:help="http://openoffice.org/2000/help"/>MsgBox oCMD1.Dbg_Properties</p>
  74.   <p class="PropText"><help:paragraphinfo state="U" number="156" xmlns:help="http://openoffice.org/2000/help"/>REM execute dialog</p>
  75.   <p class="PropText"><help:paragraphinfo state="U" number="157" xmlns:help="http://openoffice.org/2000/help"/>oDialog1.Execute()</p>
  76.   <p class="PropText"><help:paragraphinfo state="U" number="158" xmlns:help="http://openoffice.org/2000/help"/>End Sub</p>
  77.   <p class="Head3"><help:paragraphinfo state="U" number="55" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="examples; adding entry to ListBox" tag="kw68535_3" xmlns:help="http://openoffice.org/2000/help"/>Add an Entry to a ListBox</p>
  78.   <p class="PropText"><help:paragraphinfo state="U" number="122" xmlns:help="http://openoffice.org/2000/help"/>Sub AddEntry</p>
  79.   <p class="PropText"><help:paragraphinfo state="U" number="164" xmlns:help="http://openoffice.org/2000/help"/>BasicLibraries.LoadLibrary("Tools")</p>
  80.   <p class="PropText"><help:paragraphinfo state="U" number="159" xmlns:help="http://openoffice.org/2000/help"/>oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  81.   <p class="PropText"><help:paragraphinfo state="U" number="123" xmlns:help="http://openoffice.org/2000/help"/>REM adds a new entry to the ListBox</p>
  82.   <p class="PropText"><help:paragraphinfo state="U" number="124" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1Model = oDialog1.Model</p>
  83.   <p class="PropText"><help:paragraphinfo state="U" number="125" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListBox = oDialog1.GetControl("ListBox1")</p>
  84.   <p class="PropText"><help:paragraphinfo state="U" number="126" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>dim iCount as integer</p>
  85.   <p class="PropText"><help:paragraphinfo state="U" number="127" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>iCount = oListbox.ItemCount</p>
  86.   <p class="PropText"><help:paragraphinfo state="U" number="128" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListbox.additem("New Item" & iCount,0)</p>
  87.   <p class="PropText"><help:paragraphinfo state="U" number="129" xmlns:help="http://openoffice.org/2000/help"/>end sub</p>
  88.   <p class="Head3"><help:paragraphinfo state="U" number="64" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="examples; 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"><help:paragraphinfo state="U" number="130" xmlns:help="http://openoffice.org/2000/help"/>Sub RemoveEntry</p>
  90.   <p class="PropText"><help:paragraphinfo state="U" number="165" xmlns:help="http://openoffice.org/2000/help"/>BasicLibraries.LoadLibrary("Tools")</p>
  91.   <p class="PropText"><help:paragraphinfo state="U" number="160" xmlns:help="http://openoffice.org/2000/help"/>oDialog1 = LoadDialog("Standard", "Dialog1")</p>
  92.   <p class="PropText"><help:paragraphinfo state="U" number="131" xmlns:help="http://openoffice.org/2000/help"/>REM remove the first entry from the ListBox</p>
  93.   <p class="PropText"><help:paragraphinfo state="U" number="132" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oDialog1Model = oDialog1.Model</p>
  94.   <p class="PropText"><help:paragraphinfo state="U" number="133" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListBox = oDialog1.GetControl("ListBox1")</p>
  95.   <p class="PropText"><help:paragraphinfo state="U" number="134" xmlns:help="http://openoffice.org/2000/help"/><text:tab-stop xmlns:text="http://openoffice.org/2000/text"/>oListbox.removeitems(0,1)</p>
  96.   <p class="PropText"><help:paragraphinfo state="U" number="135" xmlns:help="http://openoffice.org/2000/help"/>end sub</p>
  97.   <p class="ParaList"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="65598" Eid="related" xmlns:help="http://openoffice.org/2000/help"/></p>
  98.   <p class="ParaList"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="68536" Eid="control_properties" xmlns:help="http://openoffice.org/2000/help"/></p>
  99.   <p class="ParaList"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="68530" Eid="create_dialog" xmlns:help="http://openoffice.org/2000/help"/></p>
  100.   <p class="ParaList"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="68537" Eid="insert_control" xmlns:help="http://openoffice.org/2000/help"/></p>
  101.   <p class="ParaList"><help:paragraphinfo state="S" xmlns:help="http://openoffice.org/2000/help"/><help:embedded Id="68538" Eid="show_dialog" xmlns:help="http://openoffice.org/2000/help"/></p>
  102.  </body></html>