4.01.2012

A general-purpose HTA template

HTA テンプレート

汎用的なHTA(HTML Application)のテンプレート。

・template.hta

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<html><!--
'*****************************************************************************
'*
'* NAME           :
'*
'* DESCRIPTION    :
'*
'* VERSION HISTORY:
'* 1.0  yyyy-mm-dd  Initial release by AUTHOR
'*
'*****************************************************************************
--><head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title>&nbsp;</title>
 
<script language="VBScript"><!--
'************ Initialize window size ************
resize_window 300, 84
 
'*****************************************************************************
'* Sub resize_window()
'*
'* Purpose: Resize a window to the specified width and height,
'*          and then set its position to center.
'* Input  : width - Sets the width of the window, in pixels (Integer)
'*          height - Sets the height of the window, in pixels (Integer)
'* Output : None
'*****************************************************************************
Sub resize_window(width, height)
  If width > screen.width Then width = screen.width
  If height > screen.height Then height = screen.height
  window.resizeTo width, height
  window.moveTo (screen.width - width) / 2, (screen.height - height) / 2
End Sub
--></script>
 
<HTA:APPLICATION
 ID             ="hta"
 APPLICATIONNAME="Application"
 VERSION        ="1.0"
 ICON           =""
 BORDER         ="normal"
 BORDERSTYLE    ="normal"
 CAPTION        ="yes"
 INNERBORDER    ="yes"
 MAXIMIZEBUTTON ="yes"
 MINIMIZEBUTTON ="yes"
 SHOWINTASKBAR  ="yes"
 SINGLEINSTANCE ="yes"
 SYSMENU        ="yes"
 WINDOWSTATE    ="normal"
 SCROLL         ="no"
 SCROLLFLAT     ="yes"
 SELECTION      ="no"
 CONTEXTMENU    ="yes"
 NAVIGABLE      ="no" />
 
<script language="VBScript"><!--
'*****************************************************************************
'* Sub Window_OnLoad()
'*
'* Purpose: Initialization tasks.
'* Input  : None
'* Output : None
'*****************************************************************************
Sub Window_OnLoad()
  document.title =  hta.applicationName & " v" & hta.version
End Sub
--></script>
 
<style type="text/css"><!--
body {
  font-family     : Verdana, Arial, Helvetica, Sans-serif;
  font-size       : 14px;
  font-weight     : normal;
  background-color: #ccffcc;
  color           : #000000;
  margin          : 0px 0px 0px 0px;
}
table {
  border-collapse: collapse;
  border-spacing : 0px;
  border-width   : 0px;
  border-style   : solid;
}
--></style>
</head>
 
<body>
<table width="100%">
<tr height="40px">
 <td align="center">Hello, World</td>
</tr>
</table>
</body>
</html>

・ウィンドウのリサイズ(window.resizeTo)は hta:application タグの前に記述しないと、起動時に一瞬通常サイズのウィンドウが表示されてしまう。

調べてみると、色々と奥が深い。

・実行結果
image

 

Related Posts

JavaScript版 HTAテンプレート
http://mogproject.blogspot.jp/2012/11/hta-template-with-javascript.html

 

References

HTA Template Generator
http://gallery.technet.microsoft.com/scriptcenter/HTA-Template-Generator-v1-af7273b1

0 件のコメント:

コメントを投稿