A basic HTA template

Author Message
ginolard

  • Total Posts : 1347
  • Scores: 23
  • Reward points : 0
  • Joined: 8/11/2005
  • Status: offline
A basic HTA template Thursday, December 07, 2006 12:52 AM (permalink)
0
I thought this might prove useful to the HTA virigins amongst you.  It's a very basic HTA template that demonstrates some of the most common DHTML objects

 <html>
 
 <title>HTA template</title>
 <head>
 
 <HTA:APPLICATION 
     APPLICATIONNAME="HTA Template"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     
 >
 </head>
 
 <style> 
 
 BODY
 {
        background-color: buttonface;
          Font: arial,sans-serif
        margin-top: 10px;`
        margin-left: 20px;
        margin-right: 20px;
        margin-bottom: 5px;
 }
 .button
 {
        
        width: 91px;
        height: 25px;
        font-family: arial,sans-serif;
        font-size: 8pt;
 }
 
 td
 {
        font-family: arial,sans-serif;
        font-size: 10pt;
        
 }                     
 #scroll
 {
     height:100%;
     overflow:auto;
 }
 
 SELECT.FixedWidth 
 {
  width: 17em;  /* maybe use px for pixels or pt for points here */
 }   
 
 </style>
 
 <script language="VBScript">
 Sub Window_OnLoad
 'Code to run when HTA loads goes here
 MsgBox "Hello and welcome to my HTA"
 
 'Here we add values to the Combobox called ComboBox1
 Set objOption = Document.createElement("OPTION")
 objOption.Text = "FuzzyWuzzyBunny"
 objOption.Value ="FuzzyWuzzyBunny"
 ComboBox1.Add(objOption)
 Set objOption = Document.createElement("OPTION")
 objOption.Text = "FuzzyWuzzyKitten"
 objOption.Value ="FuzzyWuzzyKitten"
 ComboBox1.Add(objOption)
 
 TextArea.InnerText="This is a text area"
 
 End Sub
 
 Sub ButtonClick
 
 MsgBox "You clicked a button!"
 
 End Sub
 
 Sub ChangeSpanArea
 If Not SpanArea.InnerText = "Text has been changed.  Click the button again to change it back" Then
    SpanArea.InnerText="Text has been changed.  Click the button again to change it back"
 Else
    SpanArea.InnerText="Click the ChangeSpanArea button to change this text"
 End If
 
 End Sub
 
 Sub ComboBoxChange
 
 MsgBox "The Value of the Combobox is currently " &  ComboBox1.Value
 
 End Sub
 
 Sub CheckBoxChange
    If CheckBox.Checked Then
        MsgBox "CheckBox is checked"
    Else
        MsgBox "CheckBox is not checked"
    End If
 End Sub
 
 Sub CheckRadioButtons
 
 
    
 
 End Sub
 </script>
 
 <body>
 <input class="button" TYPE=BUTTON value="TestButton" name="btnTestButton"  onClick="ButtonClick">
 <input class="button" TYPE=BUTTON value="ChangeSpanArea" name="btnChangeSpanArea"  onClick="ChangeSpanArea">
 <br>
 <br>
 <select size="1" class="FixedWidth" name="ComboBox1" onchange="ComboBoxChange()"></select>
 <br>
 <br>
    <table width="95%" border>
        <tr>
            <td width="20%" valign="top"><b>Row 1 Cell 1:</b></td>
            <td width="75%" valign="top">Row 1 Cell 2</td></tr>
        <tr>
        
        <tr>
            <td width="20%" valign="top"><b>Row 2 Cell 1:</b></td>
            <td width="75%" valign="top">Row 2 Cell 2</td></tr>
        <tr>
        
        <tr>
            <td width="20%" valign="top"><b>Row 3 Cell 1:</b></td>
            <td width="75%" valign="top">Row 3 Cell 2</td></tr>
        <tr>
        
        
    </table>
 <br><br>
 <span id="SpanArea" class="FixedWidth">Click the ChangeSpanArea button to change this text</span>
 <br>
 <br>
 <input type="checkbox" name="CheckBox" title="This is a checkbox" onclick="CheckBoxChange"> Click the checkbox
 <br>
 <br>
 <input type="radio" name="Radio" title="This is a Radio button" onclick="CheckRadioButtons" CHECKED>
 <input type="radio" name="Radio" title="This is a Radio button" onclick="CheckRadioButtons"> These are radio buttons
 <BR>
 <textarea style="overflow:auto" rows="7" name="TextArea" cols="70"></textarea><P align="right">
 
 
 
 </body>
 </html>
 
<message edited by ginolard on Thursday, December 07, 2006 1:30 AM>
Author of ManagePC - http://managepc.net

 
#1
    gdewrance

    • Total Posts : 591
    • Scores: 3
    • Reward points : 0
    • Joined: 3/16/2006
    • Status: offline
    RE: A basic HTA template Thursday, December 07, 2006 1:25 AM (permalink)
    0
    what happened to the closing code tag [/code]
     
    #2
      Country73

      • Total Posts : 754
      • Scores: 10
      • Reward points : 0
      • Status: offline
      RE: A basic HTA template Thursday, December 07, 2006 3:06 AM (permalink)
      0
      Noticed you didn't have anything setup in the SUB for the Radio Buttons. (What you don't like Radio Buttons that much?)

      Added the "Value" to the radio buttons:
      <input type="radio" name="Radio" title="This is a Radio button" value="RadioOne" onclick="CheckRadioButtons" CHECKED>
      <input type="radio" name="Radio" title="This is a Radio button" value="RadioTwo" onclick="CheckRadioButtons"> These are radio buttons

      Then added this small bit of code to the "Sub CheckRadioButtons"
          If Radio(0).Checked THEN
              MsgBox Radio(0).Value
          ELSE
              MsgBox Radio(1).Value
          END IF

       <html>
       
       <title>HTA template</title>
       <head>
       
       <HTA:APPLICATION
          APPLICATIONNAME="HTA Template"
          SCROLL="yes"
          SINGLEINSTANCE="yes"
          WINDOWSTATE="normal"
       
       >
       </head>
       
       <style>
       
       BODY
       {
             background-color: buttonface;
                Font: arial,sans-serif
             margin-top: 10px;`
             margin-left: 20px;
             margin-right: 20px;
             margin-bottom: 5px;
       }
       .button
       {
       
             width: 91px;
             height: 25px;
             font-family: arial,sans-serif;
             font-size: 8pt;
       }
       
       td
       {
             font-family: arial,sans-serif;
             font-size: 10pt;
       
       }
       #scroll
       {
          height:100%;
          overflow:auto;
       }
       
       SELECT.FixedWidth
       {
        width: 17em;  /* maybe use px for pixels or pt for points here */
       }
       
       </style>
       
       <script language="VBScript">
       Sub Window_OnLoad
       'Code to run when HTA loads goes here
       MsgBox "Hello and welcome to my HTA"
       
       'Here we add values to the Combobox called ComboBox1
       Set objOption = Document.createElement("OPTION")
       objOption.Text = "FuzzyWuzzyBunny"
       objOption.Value ="FuzzyWuzzyBunny"
       ComboBox1.Add(objOption)
       Set objOption = Document.createElement("OPTION")
       objOption.Text = "FuzzyWuzzyKitten"
       objOption.Value ="FuzzyWuzzyKitten"
       ComboBox1.Add(objOption)
       
       TextArea.InnerText="This is a text area"
       
       End Sub
       
       Sub ButtonClick
       
       MsgBox "You clicked a button!"
       
       End Sub
       
       Sub ChangeSpanArea
       If Not SpanArea.InnerText = "Text has been changed.  Click the button again to change it back" Then
         SpanArea.InnerText="Text has been changed.  Click the button again to change it back"
       Else
         SpanArea.InnerText="Click the ChangeSpanArea button to change this text"
       End If
       
       End Sub
       
       Sub ComboBoxChange
       
       MsgBox "The Value of the Combobox is currently " &  ComboBox1.Value
       
       End Sub
       
       Sub CheckBoxChange
         If CheckBox.Checked Then
             MsgBox "CheckBox is checked"
         Else
             MsgBox "CheckBox is not checked"
         End If
       End Sub
       
       Sub CheckRadioButtons
           If Radio(0).Checked THEN
               MsgBox Radio(0).Value
           ELSE
               MsgBox Radio(1).Value
           END IF
       End Sub
       </script>
       
       <body>
       <input class="button" TYPE=BUTTON value="TestButton" name="btnTestButton"  onClick="ButtonClick">
       <input class="button" TYPE=BUTTON value="ChangeSpanArea" name="btnChangeSpanArea"  onClick="ChangeSpanArea">
       <br>
       <br>
       <select size="1" class="FixedWidth" name="ComboBox1" onchange="ComboBoxChange()"></select>
       <br>
       <br>
         <table width="95%" border>
             <tr>
                 <td width="20%" valign="top"><b>Row 1 Cell 1:</b></td>
                 <td width="75%" valign="top">Row 1 Cell 2</td></tr>
             <tr>
       
             <tr>
                 <td width="20%" valign="top"><b>Row 2 Cell 1:</b></td>
                 <td width="75%" valign="top">Row 2 Cell 2</td></tr>
             <tr>
       
             <tr>
                 <td width="20%" valign="top"><b>Row 3 Cell 1:</b></td>
                 <td width="75%" valign="top">Row 3 Cell 2</td></tr>
             <tr>
         </table>
       <br><br>
       <span id="SpanArea" class="FixedWidth">Click the ChangeSpanArea button to change this text</span>
       <br>
       <br>
       <input type="checkbox" name="CheckBox" title="This is a checkbox" onclick="CheckBoxChange"> Click the checkbox
       <br>
       <br>
       <input type="radio" name="Radio" title="This is a Radio button" value="RadioOne" onclick="CheckRadioButtons" CHECKED>
       <input type="radio" name="Radio" title="This is a Radio button" value="RadioTwo" onclick="CheckRadioButtons"> These are radio buttons
       <BR>
       <textarea style="overflow:auto" rows="7" name="TextArea" cols="70"></textarea><P align="right">
       
       </body>
       </html>
       


       
      #3
        ginolard

        • Total Posts : 1347
        • Scores: 23
        • Reward points : 0
        • Joined: 8/11/2005
        • Status: offline
        RE: A basic HTA template Thursday, December 07, 2006 3:38 AM (permalink)
        0
        OOps.  I even created the Sub for it too! 

        Anyway, this is meant to be a constantly-updating template.  There are loads of other objects that can be added.
        Author of ManagePC - http://managepc.net

         
        #4
          Snipah

          • Total Posts : 1339
          • Scores: 8
          • Reward points : 0
          • Joined: 11/1/2004
          • Location: Scotland
          • Status: offline
          RE: A basic HTA template Tuesday, December 12, 2006 6:09 AM (permalink)
          0
          Cool,

          I would like to see the full list with all the Attributes/Properties of the HTA, and while at it, the list of HTML Attributes aswell:

          HTA: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/hta/reference/hta_ref_entry.asp

          HTML: http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

          You can provide the HTML portion with a link, but make sure that the Template holds all links/references to get ahead...


          For more information, please see the "Read me First" topic.

          http://www.visualbasicscript.com
           
          #5
            ginolard

            • Total Posts : 1347
            • Scores: 23
            • Reward points : 0
            • Joined: 8/11/2005
            • Status: offline
            RE: A basic HTA template Tuesday, December 12, 2006 11:33 PM (permalink)
            0
            Would like you that on your desk by 9am tomorrow morning Sir?
            Author of ManagePC - http://managepc.net

             
            #6
              ickleric

              • Total Posts : 92
              • Scores: 0
              • Reward points : 0
              • Joined: 11/15/2006
              • Status: offline
              RE: A basic HTA template Thursday, December 21, 2006 2:25 AM (permalink)
              0
              with the textarea when you submit it adds the text to the textfile. Is there anyway of when you submit it overwrites anything already in the text file?
               
              #7
                ickleric

                • Total Posts : 92
                • Scores: 0
                • Reward points : 0
                • Joined: 11/15/2006
                • Status: offline
                RE: A basic HTA template Thursday, December 21, 2006 2:27 AM (permalink)
                0
                never mind i've worked it out now.
                 
                although i would like to know, is there anyway of displaying the contents of the text file in a textarea?
                 
                thanks
                 
                #8
                  ginolard

                  • Total Posts : 1347
                  • Scores: 23
                  • Reward points : 0
                  • Joined: 8/11/2005
                  • Status: offline
                  RE: A basic HTA template Tuesday, December 26, 2006 8:32 PM (permalink)
                  0
                  Updated version with a button that fills the text area with the contents of an input file.
                   <html>
                   
                   <title>HTA template</title>
                   <head>
                   
                   <HTA:APPLICATION
                    APPLICATIONNAME="HTA Template"
                    SCROLL="yes"
                    SINGLEINSTANCE="yes"
                    WINDOWSTATE="normal"
                   
                   >
                   </head>
                   
                   <style>
                   
                   BODY
                   {
                       background-color: buttonface;
                          Font: arial,sans-serif
                       margin-top: 10px;`
                       margin-left: 20px;
                       margin-right: 20px;
                       margin-bottom: 5px;
                   }
                   .button
                   {
                   
                       width: 91px;
                       height: 25px;
                       font-family: arial,sans-serif;
                       font-size: 8pt;
                   }
                   
                   td
                   {
                       font-family: arial,sans-serif;
                       font-size: 10pt;
                   
                   }
                   #scroll
                   {
                    height:100%;
                    overflow:auto;
                   }
                   
                   SELECT.FixedWidth
                   {
                   width: 17em;  /* maybe use px for pixels or pt for points here */
                   }
                   
                   </style>
                   
                   <script language="VBScript">
                   Sub Window_OnLoad
                   'Code to run when HTA loads goes here
                   MsgBox "Hello and welcome to my HTA"
                   
                   'Here we add values to the Combobox called ComboBox1
                   Set objOption = Document.createElement("OPTION")
                   objOption.Text = "FuzzyWuzzyBunny"
                   objOption.Value ="FuzzyWuzzyBunny"
                   ComboBox1.Add(objOption)
                   Set objOption = Document.createElement("OPTION")
                   objOption.Text = "FuzzyWuzzyKitten"
                   objOption.Value ="FuzzyWuzzyKitten"
                   ComboBox1.Add(objOption)
                   
                   TextArea.InnerText="This is a text area"
                   
                   End Sub
                   
                   Sub ButtonClick
                   
                   MsgBox "You clicked a button!"
                   
                   End Sub
                   
                   Sub ChangeSpanArea
                   If Not SpanArea.InnerText = "Text has been changed.  Click the button again to change it back" Then
                   SpanArea.InnerText="Text has been changed.  Click the button again to change it back"
                   Else
                   SpanArea.InnerText="Click the ChangeSpanArea button to change this text"
                   End If
                   
                   End Sub
                   
                   Sub ComboBoxChange
                   
                   MsgBox "The Value of the Combobox is currently " &  ComboBox1.Value
                   
                   End Sub
                   
                   Sub FillTextArea
                   
                   Set objFSO=CreateObject("Scripting.FileSystemObject")
                   TextArea.InnerText=objFSO.OpenTextFile("c:\temp\test.txt",1).ReadAll
                   
                   End Sub
                   
                   Sub CheckBoxChange
                   If CheckBox.Checked Then
                       MsgBox "CheckBox is checked"
                   Else
                       MsgBox "CheckBox is not checked"
                   End If
                   End Sub
                   
                   Sub CheckRadioButtons
                     If Radio(0).Checked THEN
                         MsgBox Radio(0).Value
                     ELSE
                         MsgBox Radio(1).Value
                     END IF
                   End Sub
                   </script>
                   
                   <body>
                   <input class="button" TYPE=BUTTON value="TestButton" name="btnTestButton"  onClick="ButtonClick">
                   <input class="button" TYPE=BUTTON value="ChangeSpanArea" name="btnChangeSpanArea"  onClick="ChangeSpanArea">
                   <input class="button" TYPE=BUTTON value="FillTextArea" name="btnFillTextArea"  onClick="FillTextArea">
                   
                   <br>
                   <br>
                   <select size="1" class="FixedWidth" name="ComboBox1" onchange="ComboBoxChange()"></select>
                   <br>
                   <br>
                   <table width="95%" border>
                       <tr>
                           <td width="20%" valign="top"><b>Row 1 Cell 1:</b></td>
                           <td width="75%" valign="top">Row 1 Cell 2</td></tr>
                       <tr>
                   
                       <tr>
                           <td width="20%" valign="top"><b>Row 2 Cell 1:</b></td>
                           <td width="75%" valign="top">Row 2 Cell 2</td></tr>
                       <tr>
                   
                       <tr>
                           <td width="20%" valign="top"><b>Row 3 Cell 1:</b></td>
                           <td width="75%" valign="top">Row 3 Cell 2</td></tr>
                       <tr>
                   </table>
                   <br><br>
                   <span id="SpanArea" class="FixedWidth">Click the ChangeSpanArea button to change this text</span>
                   <br>
                   <br>
                   <input type="checkbox" name="CheckBox" title="This is a checkbox" onclick="CheckBoxChange"> Click the checkbox
                   <br>
                   <br>
                   <input type="radio" name="Radio" title="This is a Radio button" value="RadioOne" onclick="CheckRadioButtons" CHECKED>
                   <input type="radio" name="Radio" title="This is a Radio button" value="RadioTwo" onclick="CheckRadioButtons"> These are radio buttons
                   <BR>
                   <textarea style="overflow:auto" rows="7" name="TextArea" cols="70"></textarea><P align="right">
                   
                   </body>
                   </html>
                   
                  <message edited by Country73 on Friday, March 30, 2007 6:28 AM>
                  Author of ManagePC - http://managepc.net

                   
                  #9

                    Online Bookmarks Sharing: Share/Bookmark

                    Jump to:

                    Current active users

                    There are 0 members and 1 guests.

                    Icon Legend and Permission

                    • New Messages
                    • No New Messages
                    • Hot Topic w/ New Messages
                    • Hot Topic w/o New Messages
                    • Locked w/ New Messages
                    • Locked w/o New Messages
                    • Read Message
                    • Post New Thread
                    • Reply to message
                    • Post New Poll
                    • Submit Vote
                    • Post reward post
                    • Delete my own posts
                    • Delete my own threads
                    • Rate post

                    2000-2012 ASPPlayground.NET Forum Version 3.9