# Important notes: Users need Internet Explorer 4 or later!
#                  HTA can be real powerful. Watch out with 
#                  when using scripts from others you don't
#                  understand

# For more info, visit:
# http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp

# -------------------------------------------------- #
# Use the #define command to add the command to VDS. #
# -------------------------------------------------- #

#define command,hta
#define function,hta

  # -------------------------------- #
  # Just create a normal VDS window. #
  # -------------------------------- #
  
  DIALOG CREATE,HTA Test Window,-1,0,306,233
  DIALOG ADD,BUTTON,GetTitle,205,3,300,25,Get the titlebar value...
  DIALOG SHOW

# Create a list which holds the HTA code. Basicly this
# is just HTML code, you only have to add some headers
# Normaly the headers below are the right ones. For 
# others, go to the MSDN Library:
# http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp

# You can edit everything between <BODY> and </BODY>

list create,1
list loadtext,1
"<HEAD>
"
"  <TITLE>The HTA Title</TITLE>
"
"  <HTA:APPLICATION
"
"    Don't change these headers!
"    ---------------------------
"
"    BORDER='none'
"    CAPTION='no'
"    SINGLEINSTANCE='yes'
"    WINDOWSTATE='normal'
"    SYSMENU='yes'
"
"    The headers below can be changed.
"    ---------------------------------
"
"    CONTEXTMENU='no'
"    INNERBORDER='yes'
"    NAVIGABLE='yes'
"    SELECTION='yes'
"    SHOWINTASKBAR='no'>
"
"</HEAD>
"
"<!-- Here the BODY parts start. You can modify whatever you want... :-) -->
"
"<BODY>
"
"<p><font face='Courier New' size='2'><font color='#FF0000'><b>#define</b></font>
"<font color='#0000FF'>function,reverse<br>
"</font><br>
"<b><font color='#000080'>:reverse</font></b><br>
"<b> repeat</b><br>
"&nbsp; <font color='#FF0000'>%x</font> = <b>@substr</b>(<font color='#FF0000'>%1</font>,<font color='#FF00FF'>1</font>,<font color='#FF00FF'>1</font>)<font color='#FF0000'>%x</font><br>
"&nbsp; <font color='#FF0000'>%1</font> = <b>@strdel</b>(<font color='#FF0000'>%1</font>,<font color='#FF00FF'>1</font>,<font color='#FF00FF'>1</font>)<br>
"<b> until</b> <b>@equal</b>(<b>@len</b>(<font color='#FF0000'>%1</font>)<b>,</b><font color='#FF00FF'>0</font>)<br>
"<b> exit</b> <font color='#FF0000'> %x</font></font></p>
"
"<p><font face='Verdana' size='1'><center><a href='http://www.vdsworld.com/'>Visit VDSWORLD</a></center></font>
"
"</BODY>

# Usage: hta create,top,left,width,hight,title,list
# Title: The title you gave the file between <TITLE> and </TITLE>. The best
# way is to use a random title, so the code can easily recognize it.
# List: The list number which holds the file.
hta create,3,3,300,200,"The HTA Title",1

# Use the following line to obtain the HTA's Window Handle, which the
# @hta(GetTitle) needs to retreive the current title.
%%handle1 = @hta(LastHandle)

# You can now close the list.
list close,1

:Evloop
wait event
goto @event()

:GetTitleBUTTON
info Current title: @hta(GetTitle,%%handle1)
goto evloop

:Close
# You don't need to send a special 'close' command, because the HTA
# window is a child window of this program. I only added the close command
# so you can see which command you need to close the HTA window when 
# running your program.
hta close,%%handle1
info HTA window closed. Bye!
exit



# --------------------------------------------------------------- #
# Include this into all your programs which need HTA support. You #
# can also compile it into a DSU file.                            #
# --------------------------------------------------------------- #

:HTA
if @equal(%1,create)
  # -------------------------------------------------- #
  # Sytax: hta create,top,left,width,height,title,list #
  # -------------------------------------------------- #
  # Save the list to a file and open it.               
  list savefile,%7,@windir(T)\%6.HTA
  shell open,@windir(T)\%6.HTA
  # -------------------------------------------------- #
  # Wait until the file is opened.
  repeat 
  wait 0.00000000000000000001
  until @winexists(%6)
  # -------------------------------------------------- #
  # Once the file is opened, change the position to    
  # the right onces.                                   
  window position,@winexists(%6),%2,%3,%4,%5
  # -------------------------------------------------- #
  # Then set the parent window to the opened VDS       
  # window with the use of the Windows API.            
  loadlib user32
  # This writes the handle to a variable, so you can use it
  # to obtain the titlebar value. 
  %%htawindowhandle = @strdel(@winexists(%6),1,1)
  %%tempvariable = @lib(user32,SetParent,INT:,@strdel(@winexists(%6),1,1),@strdel(@win(@dlgtext()),1,1))
  freelib user32
  # -------------------------------------------------- #
  end

if @equal(%1,LastHandle)
  # This passes the handle of the last opened HTA window to
  # the programmer.
  exit "%"%%htawindowhandle
  end

if @equal(%1,GetTitle)
  # This gives the titlebar value of the HTA window.
  exit @wintext(%2)
  end
  
if @equal(%1,Close)
  window close,%2
  end
  
exit
