A notepad made in HTA(hta实现的记事本)_hta

This notepad can handle bigger files than the one shiped with Win9x.
Learn how to make windows looking interfaces in HTML.
Interesting use of Commondialogs.

效果图:

复制代码 代码如下:

<html><head>

<HTA:APPLICATION
 APPLICATIONNAME="HTANotePad" ID="oHTA" BORDER="thick"
 BORDERSTYLE="normal" CAPTION="yes" CONTEXTMENU="yes"
 INNERBORDER="no" MAXIMIZEBUTTON="yes" MINIMIZEBUTTON="yes"
 NAVIGABLE="yes"
 ICON="NOTEPAD.EXE" SCROLL="no" SCROLLFLAT="no"
 SELECTION="no" SHOWINTASKBAR="yes" SINGLEINSTANCE="no"
 SYSMENU="yes" VERSION="0.3" WINDOWSTATE="normal">

<STYLE TYPE="text/css">
<!--
BODY { xfont-family: "Verdana, Arial, Helvetica, sans-serif";
  font:menu;
  background-color:Menu;
  color:MenuText;
  xfont-size: 8pt;
  cursor:default; //auto, text, pointer
 }
TABLE { xfont-family:"Arial";
  xfont-size:8pt;
  font:menu;
  padding:0pt;
  border:0pt;
  FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=90);
 }
IFrame { height:expression(document.body.clientHeight-MenuTable.clientHeight);
  width:100%;
 }
TD { border:"1px solid Menu";}
.submenu {position:absolute;top=20;
  background-color:Menu;
  border="2px outset";}
.MenuIn  {border:'1px inset';}
.Menuover {border:'1px outset';}
.Menuout {border:'1px solid';}
.Submenuover {background-color:highlight;color:highlighttext;}
.Submenuout {background-color:Menu;color:MenuText;}
-->
</STYLE>

<script language=vbscript>
option explicit
Dim FileName,fModif,LastChildMenu,LastMenu
fModif=False 'Not modified
DisplayTitle
Set LastChildMenu=Nothing
Set LastMenu=Nothing
Sub DisplayTitle
 If FileName="" Then
  document.Title="sans titre - " & oHTA.ApplicationName
 Else
  document.Title=FileName & " - " & oHTA.ApplicationName
 End If
End Sub

'''''''''''''''''''
' File management '
'''''''''''''''''''
Sub SaveAs
 Dim oDLG
 Set oDLG=CreateObject("MSComDlg.CommonDialog")
 With oDLG
  .DialogTitle="SaveAs"
  .Filter="Scripts|*.vbs;*.hta;*.wsf;*.js|Text Files|*.txt|All files|*.*"
  .MaxFileSize=255
  .ShowSave
  If .FileName<>"" Then
   FileName=.FileName
   Save
  End If
 End With
 Set oDLG=Nothing
 DisplayTitle
End Sub
Sub Save()
 Dim fso,f
 If FileName<>"" Then
  Set fso=CreateObject("Scripting.FileSystemObject")
  Set f=fso.CreateTextFile(FileName,True)
  f.Write MyFrame.MyText.Value
  f.Close
  Set f=Nothing
  Set fso=Nothing
 Else
  SaveAs
 End If
End Sub
Sub OpenIt
 Dim fso,f
 Set fso=CreateObject("Scripting.FileSystemObject")
 Set f=fso.OpenTextFile(FileName,1)
 MyFrame.MyText.Value=f.ReadAll
 f.close
 Set f=Nothing
 Set fso=Nothing
 DisplayTitle
End Sub
Sub Open()
 If fModif Then
  Select Case Msgbox("The text in the file " & FileName & " has been changed." _
   & vbCrLf & "Do you want to save the changes ?",51,oHTA.ApplicationName)
  Case 6 'Yes
   Save
  Case 7 'No
  Case 2 'Cancel
   Exit Sub
  End Select
 End If
 Dim oDLG
 Set oDLG=CreateObject("MSComDlg.CommonDialog")
 With oDLG
  .DialogTitle="Open"
  .Filter="Scripts|*.vbs;*.hta;*.wsf;*.js|Text Files|*.txt|All files|*.*"
  .MaxFileSize=255
  .Flags=.Flags Or &H1000 'FileMustExist (OFN_FILEMUSTEXIST)
  .ShowOpen
  If .FileName<>"" Then
   FileName=.FileName
   OpenIt
  End If
 End With
 Set oDLG=Nothing
End Sub
Sub NewText
 If fModif Then
  Select Case Msgbox("The text in the file " & FileName & " has been changed." _
   & vbCrLf & "Do you want to save the changes ?",51,oHTA.ApplicationName)
  Case 6 'Yes
   Save
  Case 7 'No
  Case 2 'Cancel
   Exit Sub
  End Select
 End If
 MyFrame.MyText.Value=""
 FileName=""
 DisplayTitle
End Sub

'''''''''''''''
' Drag & Drop '
'''''''''''''''
Sub ChangeIFrame
 'We use an Iframe to allow Drag&Drop
 MyFrame.Document.Body.InnerHTML="<textarea ID=MyText WRAP=OFF onChange" & _
  "='vbscript:parent.fModif=True' onclick='vbscript:parent.HideMenu' " & _
  "style='width:100%;height:100%'></textarea>"
 With MyFrame.Document.Body.Style
  .marginleft=0
  .margintop=0
  .marginright=0
  .marginbottom=0
 End With
 With MyFrame.MyText.Style
  .fontfamily="Fixedsys, Verdana, Arial, sans-serif"
  '.fontsize="7pt"
 End With
 Select Case UCase(MyFrame.location.href)
 Case "ABOUT:BLANK"
  FileName=""
 Case Else
  FileName=Replace(Mid(MyFrame.location.href,9),"/","\") 'suppress file:///
  OpenIt
 End Select
End Sub

'''''''''''''''''''
' Menu management '
'''''''''''''''''''
Sub ShowSubMenu(Parent,Child)
 If Child.style.display="block" Then
  Parent.classname="Menuover"
  Child.style.display="none"
  Set LastChildMenu=Nothing
 Else
  Parent.classname="Menuin"
  Child.style.display="block"
  Set LastChildMenu=Child
 End If
 Set LastMenu=Parent
End Sub
Sub MenuOver(Parent,Child)
 If LastChildMenu is Nothing Then
  Parent.className="MenuOver"
 Else
  If LastMenu is Parent Then
   Parent.className="MenuIn"
  Else
   HideMenu
   ShowSubMenu Parent,Child
  End If
 End If
End Sub
Sub MenuOut(Menu)
 If LastChildMenu is Nothing Then Menu.className="MenuOut"
End Sub
Sub HideMenu
 If Not LastChildMenu is Nothing Then
  LastChildMenu.style.display="none"
  Set LastChildMenu=Nothing
  LAstMenu.classname="Menuout"
 End If
End Sub
Sub SubMenuOver(Menu)
 Menu.className="SubMenuOver"
 'LastMenu.classname="Menuin"
End Sub
Sub SubMenuOut(Menu)
 Menu.className="SubMenuOut"
End Sub

</script>
</head>

<body leftmargin=0 topmargin=0 rightmargin=0>
<TABLE id=MenuTable><TR>
 <TD onclick='ShowSubMenu Me,MyFileMenu'
  onmouseover='MenuOver Me,MyFileMenu'
  onmouseout='MenuOut Me'> File </TD>
 <TD onclick='ShowSubMenu Me,MyEditMenu'
  onmouseover='MenuOver Me,MyEditMenu'
  onmouseout='MenuOut Me'> Edit </TD>
 <TD onclick='ShowSubMenu Me,MyFindMenu'
  onmouseover='MenuOver Me,MyFindMenu'
  onmouseout='MenuOut Me'> Find </TD>
 <TD onclick='ShowSubMenu Me,MyHelpMenu'
  onmouseover='MenuOver Me,MyHelpMenu'
  onmouseout='MenuOut Me'> ? </TD>
 <TD onclick="HideMenu" width=100% border=2></TD>
 </TR></TABLE>
<TABLE ID=MyFileMenu class=submenu style="left=2;display:none;"><TR>
 <TD onclick="HideMenu:NewText"
  onmouseover='Submenuover Me'
  onmouseout='Submenuout Me'> New</TD></TR>
 <TR><TD onclick="HideMenu:open"
  onmouseover='Submenuover Me'
  onmouseout='Submenuout Me'> Open</TD></TR>
 <TR><TD onclick="HideMenu:save"
  onmouseover='Submenuover Me'
  onmouseout='Submenuout Me'> Save</TD></TR>
 <TR><TD onclick="HideMenu:saveAs"
  onmouseover='Submenuover Me'
  onmouseout='Submenuout Me'> Save As</TD></TR>
 <TR><TD><HR></TD></TR>
 <TR><TD onclick="HideMenu:window.close"
  onmouseover='Submenuover Me'
  onmouseout='Submenuout Me'> Quit</TD></TR>
 </TABLE>
<TABLE ID=MyEditMenu class=submenu style="left=30;display:none;"><TR>
 <TD><HR width=50px></TD></TR>
 </TABLE>
<TABLE ID=MyFindMenu class=submenu style="left=60;display:none;"><TR>
 <TD><HR width=50px></TD></TR>
 </TABLE>
<TABLE ID=MyHelpMenu class=submenu style="left=90;display:none;"><TR>
 <TD onclick='HideMenu:msgbox "No help available yet;under construction ;=)"'
  onmouseover='Submenuover Me'
  onmouseout='Submenuout Me'>Help</TD></TR>
 <TR><TD onclick='HideMenu:CreateObject("MSComDlg.CommonDialog").AboutBox'
  onmouseover='Submenuover Me'
  onmouseout='Submenuout Me'>About</TD></TR>
 </TABLE>

<iframe id=MyFrame application=yes scrolling=no onload="ChangeIFrame"></iframe>

<script language=vbscript>
'We can handle a file as a parameter to this HTA
Dim x
FileName=Trim(oHTA.CommandLine)
x=Instr(2,FileName,"""")
If x=Len(FileName) Then
 FileName="" 'No File Loaded
Else
 FileName=Trim(Mid(FileName,x+1))
 OpenIt
End If
</script>
</body></html>

时间: 2024-08-01 03:15:08

A notepad made in HTA(hta实现的记事本)_hta的相关文章

从 HTA 中启动应用程序_hta

如何从 HTA 中启动应用程序? 问: 您好,脚本专家!对于 HTA,有没有什么可以替代 Wscript.Shell 命令?我需要运行某个应用程序并指定要打开的文件. -- DL 答: 您好,DL.是的,我们确实知道这样的命令,可以在 HTA 中使用并可以替代 Wscript.Shell 命令,我们一会儿就会向您介绍.不过,在介绍它之前,我们应注意到您实际上可以在 HTA 中使用 Wscript.Shell 对象.这是一个常会引发混淆之处:因为您在 HTA 中无法使用某些命令(如 Wscript

A notepad made in HTA(hta实现的记事本)

这个记事本可以在Win9x中运行,并且处理更大的文件.可以通过修改html修改页面,喜欢学习hta的朋友可以参考下   This notepad can handle bigger files than the one shiped with Win9x. Learn how to make windows looking interfaces in HTML. Interesting use of Commondialogs. 效果图: 复制代码 代码如下: <html><head&g

hta 实现的五子棋界面_hta

保存为 五子棋.hta,运行即可看到效果 <html> <title>五子棋界面 - zh159</title> <hrad> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <HTA:APPLICATION ID="MyhyliApp" APPLICATIONNAME="五子棋界面

hta实现的涂鸦效果_hta

hta:HTML Applications  hta是html的可执行程序,制作很简单,将文件*.htm改为*.hta就可以了. 不过hta有自己独有的标签<hta>,并可设置其属性达到很不错的效果. hta是制作小程序绝佳选择. 下面是一个例子,几天前在公司无聊时写的. 代码: 复制代码 代码如下: <HTML>  <HEAD>  <HTA:APPLICATION  CAPTION="no"  SCROLL="no"  S

ScriptomaticV2.hta学习脚本好工具_hta

复制代码 代码如下: <html> <!-- '******************************************************************** '* '*  File:          Scriptomatic.hta '*  Author:        The Scripting Guys, Microsoft Corporation '*  Created:       August 2002 '*  Modified:      Jul

hta实现涂鸦效果代码_hta

复制代码 代码如下: <html>      <head>      <hta:APPLICATION      CAPTION="no"      SCROLL="no"      SHOWINTASKBAR="no"      INNERBORDER="no"      CONTEXTMENU="no"      BORDER="none"      S

如何使一个HTA位于屏幕中心(Win32_DesktopMonitor)_hta

我们可以调整(如果需要)窗口大小并使其居中,但这样做时会在屏幕上出现瞬间的闪烁.这并不是太明显,其实际结果就是你所期望的:HTA 会位于屏幕中心.我们希望这个过程变得稍微流畅些,但目前我们不得不使用此方法. 下面是 HTA 示例的代码.(若要实现此过程,请复制该代码,并将其粘贴到记事本中,然后以 .hta 为文件扩展名保存该文件.)我们担心的部分(也是唯一真正有用的部分)是 Window_Onload 子例程,每当 HTA 被加载或更新时,该子例程就自动运行: 复制代码 代码如下: <html>

在Windows下使用Notepad++和xdebug调试php脚本

介绍 Notepad++ 是开放源代码的可替代记事本的编辑器.它运行于 MS Windows 环境,支持多种编程语言.可以浏览 http://notepad-plus.sourceforge.net/ 了解更多相关信息. Xdebug 是 php 的一个扩展,它提供了对 php 脚本进行除错.追踪.检查的各种功能.可以浏览 http://xdebug.org 了解更多相关信息. 下载 Notepad++ 下载地址:http://nchc.dl.sourceforge.net/sourceforg

IIS中的MIME格式

iis|mime IIS中的MIME格式,按类型/子类型排序 下面的表格列出了按MIME内容类型/子类型排序的MIME内容类型,这些类型是在IIS 4.0 和IIS 5.0中注册的. 类型/子类型 扩展名 IIS 4.0 IIS 5.0 application/envoy evy 是 是 application/fractals fif 否 是 application/futuresplash spl 否 是 application/hta hta 否 是 application/interne