forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


HTA Support (HTML)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1054
Location: India

PostPosted: Sat Aug 30, 2003 10:56 am    Post subject: Reply with quote

I have added some changes to the code so that it looks more proffessional without explosions etc.
I have added a API to open and reodered some code lines and added a routine to prevent hang in case the hta cannot be opened.
You need a test.htm in the same directory as the .dsc to test it.
I did this just to show how to open any html file of your choice at startup just like any browser.
Code:

# 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...
  # --------------------------------------------------------------------------- #
  # Add the HTA to the Apllication                                              #
  # Sytax: hta create,top,left,width,height,title,htmlfilenamewithapth.ext,list #
  # --------------------------------------------------------------------------- #
  HTA CREATE,3,3,300,200,"The HTA Title",@PATH(%0)test.htm,1
  DIALOG SHOW

# Use the following line to obtain the HTA's Window Handle, which the
  %%handle1 = @hta(LastHandle)
# @hta(GetTitle) needs to retreive the current title.

: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)
# 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

# 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.
list create,%8
list loadfile,%8,%7
%M = @MATCH( %8,<body)
 IF @EQUAL(%M,1)
 %M = @INDEX(%8)
  ELSE
 REM The htm(l) file should contain <body> tag else you get error
 REM Most htm(l) conatin that.
 REM "Avoid opening a htm file with scripts you don't understand
 REM HTA's are trusted applications with full privileges to
 REM access your system".
 WARN The htm"(l)" file is in a invalid format !
 ERROR 20
END
%A = 0
LIST SEEK,%8,0
REPEAT
%A = @SUM(%A,1)
LIST DELETE,%8
UNTIL @EQUAL(%A,%M)
%B = @TEXT(%8)
list clear,%8
list loadtext,%8
"
"  <HTA:APPLICATION
"
"    Don't change these headers!
"    ---------------------------
"
"    BORDER='none'
"    CAPTION='no'
"    SINGLEINSTANCE='yes'
"    WINDOWSTATE='minimize'
"    SYSMENU='yes'
"
"    The headers below can be changed.
"    ---------------------------------
"
"    CONTEXTMENU='no'
"    INNERBORDER='1'
"    NAVIGABLE='yes'
"    SELECTION='yes'
"    SHOWINTASKBAR='yes'>
"
"</HEAD>
LIST APPEND,%8,%B
LIST SEEK,%8,0
list INSERT,%8,<HEAD>
list INSERT,%8,""
List INSERT,%8,<TITLE>%6</TITLE>
LIST SAVEFILE,%8,@WINDIR(T)\%6.HTA
LIST CLOSE,%8
  # --------------------------------------------------------------------------- #
  # Sytax: hta create,top,left,width,height,title,htmlfilenamewithapth.ext,list #
  # --------------------------------------------------------------------------- #
  # Save the list to a file and open it.
LOADLIB KERNEL32
%F = @WINDIR(S)\mshta.exe @SHORTNAME(@WINDIR(T)\%6.HTA)
%Z = @LIB(KERNEL32,WinExec,INT:,@ADDR("%F"),7)
REM "Constant 7 in the above function means
REM show the window in minimized and non active state"
REM WinExec is a old API but allows you to specify
REM the initial state of the window unlike vds "shell" command.
FREELIB KERNEL32
  # -------------------------------------------------- #
  # Wait until the file is opened.
  %z = 0
  repeat
  %z = @SUM(%z,1)
  wait 0.00000000000000000001
  %W = @winexists(%6)
  #"Code to time out just in case the hta could not be opened
  #chang the timeout value as per your conveniece
  #if you donot add this code window will hang
  #due a infinite loop"
  #I have just used "warn" but you can chosoe to get the current
  #process id using API and make your app commit suicide.
  IF @GREATER(%Z,50)
   WARN The HTA file could not be opened !
   %W = 1
   END
  until %W
  # -------------------------------------------------- #
  # Once the file is opened, change the position to   
  # the right onces.                                   
  # -------------------------------------------------- #
  # 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
  window position,%W,%2,%3,%4,%5
  # -------------------------------------------------- #
  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

___________________________________________________________________________________________________________

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group