Change the title color and background

7.6k Views Asked by At

How would I do the title color and background of the HTA using the arguments?

something like:

List.hta "ColorBG" "ColorTitle"

Title:

<font color="#FFFFFF" Times New Roman" size="13"><center><B>List</b></center></font>

.

My Full code:

<html>
 <head>
  <title>My List</title>
 <HTA:Application
      Border= "thin"
      Application="/md/input"
      Scoll="NO"
      Singleinstance="Yes"
      SysMenu=NO
      Icon="%Windir%\System32\wscript.exe">
      ShowInTaskbar="Yes"
      Caption="Yes">
  <script type="text/vbscript">
Option Explicit
    Window.resizeTo 373,610
Const csFSpec = "List.txt"
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")

Sub Window_OnLoad()
Dim objFile
If goFS.FileExists(csFSpec) Then
    SET objFile = goFS.GetFile(csFSpec)
    If objFile.Size > 0 Then
        document.all.DataArea.value = goFS.OpenTextFile(csFSpec).ReadAll()
        document.all.DataArea.value = document.all.DataArea.value
    Else
        document.all.DataArea.value =""
    End If
Else

     self.close
  End If
End Sub

Sub SaveFile()

Dim objMM
Dim objFSOO
If document.all.DataArea.value = "" Then
Set objFSOO = CreateObject("Scripting.FileSystemObject")
Set objMM = objFSOO.CreateTextFile("List.txt")
     self.close
Else
document.all.DataArea.value = Replace(document.all.DataArea.value, "\", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "/", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, ":", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "*", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "?", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, """", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "<", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, ">", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "|", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "&", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "!", "_")
  goFS.CreateTextFile(csFSpec).Write document.all.DataArea.value

  DIM objFSO
  DIM objFile
  DIM STRLINE
  DIM STRNEWCONTENTS

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("List.txt", ForReading)

Do Until objFile.AtEndOfStream
    strLine = objFile.Readline
    strLine = Trim(strLine)
    If Len(strLine) > 0 Then
        strNewContents = strNewContents & strLine & vbCrLf
    End If
Loop

objFile.Close

Set objFile = objFSO.OpenTextFile("List.txt", ForWriting)
objFile.Write strNewContents
objFile.Close

     document.all.DataArea.value = goFS.OpenTextFile(csFSpec).ReadAll()
     document.all.DataArea.value = Replace(document.all.DataArea.value, vbcrlf,"|")
     document.all.DataArea.value = left(document.all.DataArea.value,len(document.all.DataArea.value)-1)
     document.all.DataArea.value = Replace(document.all.DataArea.value,"|",vbcrlf)
     goFS.CreateTextFile(csFSpec).Write document.all.DataArea.value

     self.close
  End if
End Sub

Sub QuitEdit()

     self.close
End Sub

Sub Redefine()

document.all.DataArea.value ="CD" & vbcrlf & "DISC" & vbcrlf & "MUSIC" & vbcrlf & "ALBUM"

End Sub

Sub Clean()

document.all.DataArea.value = ""

End Sub
  </script>
 </head>
<body style="overflow:hidden" bgColor="#000080"></body>
<caption></caption><hr></hr>
<font color="#FFFFFF" Times New Roman" size="13"><center><B>List</b></center></font>
<caption></caption><hr></hr>
     <TR><td>
<input style="background-color:#F0F0F0; color: #000000; border: 2px transparent; float: left;" type="BUTTON" value="Clean" class="btn" id="btna" onclick="Clean" onmouseover="btna.style.background = '#808080'" onmouseout="btna.style.background = '#F0F0F0'">
<input style="background-color:#F0F0F0; color: #000000; border: 2px transparent; float: right;" type="BUTTON" value="Redefine" class="btn" id="btnb" onclick="Redefine" onmouseover="btnb.style.background = '#808080'" onmouseout="btnb.style.background = '#F0F0F0'">
   </TR></td>
   <Table border="3"  style="width:100%; text-align: center" BORDERCOLOR=#F0F0F0>
   <TR><td>
  <form>
<textarea name="DataArea" rows="23" cols=37></textarea>  </Table>
   <TR><td>
   <p>
 <div align="right"><input style="background-color:#F0F0F0; color: #000000; border: 2px transparent" type="BUTTON" value=" OK " class="btn" id="btnc" onclick="SaveFile" onmouseover="btnc.style.background = '#808080'" onmouseout="btnc.style.background = '#F0F0F0'">
<input style="background-color:#F0F0F0; color: #000000; border: 2px transparent" type="BUTTON" value="Cancel" class="btn" id="btnd" onclick="QuitEdit" onmouseover="btnd.style.background = '#808080'" onmouseout="btnd.style.background = '#F0F0F0'">
   </div>
  </td></TR>
  </form>
 </body>
</html>
1

There are 1 best solutions below

0
On BEST ANSWER

The text between <title> and </title> cannot be styled. It's used to set Internet Explorer's Window title in the caption/title bar. Any text you enter will be treated literally.

Windows controls the look of all caption bars. You can configure them (globally) in the "Appearance" or "Windows Color" section of the Display/Personalization applet in the Control Panel. For example, "Active Title Bar" controls the font and colors Windows uses for the currently-active window.

Edit:

I reread you question and it sounds like maybe your "title" is not the page title (<title>) but just some text you're displaying near the top of your page (that you're calling your "title").

You can pass args to an HTA but it's a little tricky to parse them. HTA's only have the CommandLine property, which returns the full command line, including the full path to your HTA. To make things easier, most people choose to enclose their args in quotes, so your command line might look like this:

"c:\my folder\test.hta" "#ddd" "#f00"

Here, we're passing two args (HTML colors) to an HTA. To retrieve them, we can split the CommandLine property on quotes (Chr(34)) and we'd get the following:

a = Split(myhta.CommandLine, Chr(34))
a(0) = <blank>
a(1) = "c:\my folder\test.hta"
a(2) = " "
a(3) = "#ddd"
a(4) = " "
a(5) = "#f00"
a(6) = <blank>

So, a(3) becomes your first arg and a(5) becomes your second. Now you can just assign these values to your HTML element's style.backgroundColor and style.color properties.

Here's an example:

<head>
    <HTA:APPLICATION
        ID="htatest" 
        APPLICATIONNAME="HTA Test"
    >
</head>

<body>
    <span id="mytitle">This is a title</span>
</body>

<script language="VBScript">
    Sub Window_OnLoad()
        a = Split(htatest.CommandLine, Chr(34))
        mytitle.style.backgroundcolor = a(3)
        mytitle.style.color = a(5)
    End Sub
</script>