4.22.2012

Calendar control in HTA

HTA: カレンダーコントロール

HTA から Microsoft Office の ActiveX コントロールを呼び出す例。(要Office環境/Office 2010を除く)

・calendar.hta

<html><!--
'*****************************************************************************
'*
'* NAME           : Simple Calendar
'*
'* DESCRIPTION    : Displays the selected date.
'*
'* VERSION HISTORY:
'* 1.0  2012-04-22  Initial release by mogproject
'*
'*****************************************************************************
--><head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title>&nbsp;</title>

<script language="VBScript"><!--
'************ Initialize window size ************
resize_window 300, 300

'*****************************************************************************
'* 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="Simple Calendar"
 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
  Calendar_AfterUpdate
End Sub

'*****************************************************************************
'* Sub Calendar_AfterUpdate()
'*
'* Purpose: Update date string.
'* Input  : None
'* Output : None
'*****************************************************************************
Sub Calendar_AfterUpdate()
  divDate.innerHtml = Calendar.Value
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>
 <td>
  <object id="Calendar" classid="clsid:8e27c92b-1264-101c-8a2f-040224009c02"
   width="100%" height="200px"></object>
 </td>
</tr>
<tr height="40px">
 <td align="center"><div id="divDate" /></td>
</tr>
</table>
</body>
</html>

0 件のコメント:

コメントを投稿