如何有效修改Hta显示的Icon图标和Hta标题栏状态栏图标

dh20156 2009-06-08 10:49:40
因项目需求,需要制作一个客户端工具,由于开发时间的原因,我们选择使用hta的方式来开发,一切进展顺利,美中不足就是hta的icon显示图标不太美观,更惨的是它没有更换图标的选项,经过一番搜索实践,终于改变了hta的icon显示图标,当然,hta的标题栏和状态栏图标设置就很简单了!


hta项目文件结构

【项目文件夹】

├ 【source】

│ ├ 要执行的hta文件.hta

│ └ 要给这个hta使用的icon图标.ico

└ 【其他项目需要的目录(与设置hta图标无关)】


设置hta的标题栏和状态栏图标

在hta文件的<HTA:APPLICATION ...>中添加如下属性:

ICON="要给这个hta使用的icon图标.ico"


设置hta的显示图标

给hta设置显示图标目前为止貌似都没有直接的方式,网上搜索到一些方式:
exeScript

使用exeScript必须是ANSI格式才行,否则乱码,而且转换成exe后不能支持AJAX的后台操作,会弹出IE窗口,失败...
Netbox

没有试过
WinRar

突破就是它了!
实现原理:利用WinRar的创建自解压格式压缩文件来打包hta项目包并且给创建后的文件添加一个ICON图标

1.在【项目文件夹】上点右键,选择WinRar选项中的“添加到压缩文件”

2.在弹出的对话框【压缩选项】中勾选“创建自解压格式压缩文件”

3.切换到【高级】选项卡,单击“自解压选项”

4.在【自解压选项】对话框中进行如下操作:

4.1 在“解压路径”中填写一个预计客户端存在的路径,如:c:\

4.2 在“解压后运行”中填写我们那个hta文件解压后的路径,如:c:\项目文件夹\要执行的hta文件.hta

4.3 切换到【模式】选项卡,在“安静模式”中选中“全部隐藏”,在“覆盖方式”中选中“跳过已经存在的文件”

4.4 切换到【文本和图标】选项卡,在“从文件加载自解压文件图标”中点【浏览】按钮,选择我们要使用的hta图标ICON文件,如:在弹出的图标文件选择框中打开【项目文件夹】->【source】,然后选中“要给这个hta使用的icon图标.ico”这个图标

4.5 确定

5. 确定

执行完上述操作后,将会生成一个显示着我们要使用的图标的exe文件,双击执行看看,马上就弹出了我们要执行的那个hta文件,看它的标题栏和状态栏图标,也OK了,最终,蒙混过关。

如果大家发现其他更好的给hta文件更改显示图标的方式,还望共享学习一下!

原创文章,转载请注明出处http://www.w3cgroup.com/article.asp?id=254


参考:<HTA:APPLICATION ...>属性介绍
该标签需写入到<head></head>内,写法形如:

<HTA:APPLICATION

ID="W3CGROUP"

属性="属性值"

>

applicationName
Sets or retrieves the name of the HTML Application (HTA).
设置或者获取HTA的名称
值:自定义

border
Sets or retrieves the type of window border for the HTML Application (HTA).
设置边框模式
值为:thick/thin/dialog/none

borderStyle
Sets or retrieves the style set for the content border within the HTML Application (HTA) window.
设置边框样式
值为:normal/complex/raised/static/sunken

caption
Sets or retrieves a Boolean value that indicates whether the window is set to display a title bar or caption, for the HTML Application (HTA).
是否显示标题栏
值为yes/no

commandLine
Retrieves the argument used to launch the HTML Application (HTA).
用于获取当前HTA应用程序的路径

contextMenu
Sets or retrieves whether the context menu is displayed when the right mouse button is clicked.
设置或者获取反键菜单是否可用
值为yes/no

icon
Sets or retrieves the name and location of the icon specified in the HTML Application (HTA).
设置HTA的图标路径
值为一个图标路径

innerBorder
Sets or retrieves whether the inside 3-D border is displayed.
是否显示内边框
值为yes/no

maximizeButton
Sets or retrieves a Boolean value that indicates whether a Maximize button is displayed in the title bar of the HTML Application (HTA) window.
是否显示最大化按钮
值为yes/no

minimizeButton
Sets or retrieves a Boolean value that indicates whether a Minimize button is displayed in the title bar of the HTML Application (HTA) window.
是否显示最小化按钮
值为yes/no

navigable
Sets or retrieves whether linked documents will be loaded in the main HTA window or in a new browser window.
设置HTA程序中的链接是在浏览器中打开,还是
在当前窗口打开.
值为yes/no

scroll
Sets or retrieves whether the scroll bars are displayed.
是否显示滚动条
值为yes/no/auto

scrollFlat
Sets or retrieves whether the scroll bar is 3-D or flat.
设置滚动条是3D样式的,还是2D平板样式
值为yes/no

selection
Sets or retrieves whether the content can be selected with the mouse or keyboard.
设置HTA中的文字是否可选
值为yes/no

showInTaskBar
Sets or retrieves a value that indicates whether the HTML Application (HTA) is displayed in the Windows taskbar.
设置HTA是否显示在任务栏上
值为yes/no

singleInstance
Sets or retrieves a value that indicates whether only one instance of the specified HTML Application (HTA) can run at a time.
设置同一个HTA能否以多窗口模式打开
值为yes/no

sysMenu
Sets or retrieves a Boolean value that indicates whether a system menu is displayed in the HTML Application (HTA).
设置是否显示系统的几个按钮,最大化,最小化
值为yes/no

version
Sets or retrieves the version number of the HTML Application (HTA).
设置HTA版本信息

windowState
Sets or retrieves the initial size of the HTA window.
设置HTA打开时的模式
值为normal/maximize/minimize
...全文
364 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuStanly 2011-04-01
  • 打赏
  • 举报
回复
考古,但有用.
dh20156 2009-06-11
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 zswang 的回复:]
我特喜欢用hta写小工具,这东西不用安装开发和调试环境。
[/Quote]

呵呵,我也写了好些个鸟~~~``` ^_^
2009-06-11
  • 打赏
  • 举报
回复
王集鹄 2009-06-11
  • 打赏
  • 举报
回复
我特喜欢用hta写小工具,这东西不用安装开发和调试环境。
王集鹄 2009-06-11
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 dh20156 的回复:]
引用 11 楼 zswang 的回复:

清洁工素8素在扫帖子? ^_^
[/Quote]非诚勿顶。
dh20156 2009-06-10
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 zswang 的回复:]

[/Quote]

清洁工素8素在扫帖子? ^_^
王集鹄 2009-06-10
  • 打赏
  • 举报
回复
monexus 2009-06-08
  • 打赏
  • 举报
回复
学习一下
wtcsy 2009-06-08
  • 打赏
  • 举报
回复
Up
记录 学习!~
dh20156 2009-06-08
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 cuixiping 的回复:]
<HTA:APPLICATION
ICON="hello.ico"
/>
这样就可以,图标路径改成你自己的图标的路径,相对路径或者绝对路径都可以。

[/Quote]

恩,这是设置hta的标题栏和状态栏图标!
cuixiping 2009-06-08
  • 打赏
  • 举报
回复
<HTA:APPLICATION
ICON="hello.ico"
/>
这样就可以,图标路径改成你自己的图标的路径,相对路径或者绝对路径都可以。
hookee 2009-06-08
  • 打赏
  • 举报
回复
~jF
dh20156 2009-06-08
  • 打赏
  • 举报
回复
自己沙发! ^_^
william3033 2009-06-08
  • 打赏
  • 举报
回复
mark
收藏了,你的帖子介绍的真详细,看着舒服。
xiangtanboy 2009-06-08
  • 打赏
  • 举报
回复
学习学习. 前几天也发现rar打包的时候可以选图标
APM60- 2009-06-08
  • 打赏
  • 举报
回复
强人啊~~~
用WinRar蒙混…
额~ 又学了一招。
xiaojing7 2009-06-08
  • 打赏
  • 举报
回复
JF

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧