找回密码
 加入
搜索
查看: 5181|回复: 12

按钮中使用EXE图标的方法

 火.. [复制链接]
发表于 2010-1-4 13:07:02 | 显示全部楼层 |阅读模式
本帖最后由 hzxymkb 于 2010-1-4 15:04 编辑
#include <GuiButton.au3>
#include <GuiImageList.au3>
#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 501, 290, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 144, 80, 147, 33,$BS_FLAT)
$hImage= _GUIImageList_Create(20, 20, 5, 1, 0)
_GUIImageList_AddIcon($hImage,"shell32.dll", 1, True)
_GUICtrlButton_SetImageList(-1, $hImage)
GUISetState(@SW_SHOW) 
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
我想把上面代码中的shell32.dll改成C:\Program Files\TTPlayer\TTPlayer.exe,让图标能在按钮中显示!有什么办法呀!
发表于 2010-1-4 14:12:50 | 显示全部楼层
本帖最后由 顽固不化 于 2010-1-4 14:15 编辑
#include <GuiButton.au3>
#include <GuiImageList.au3>
#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 501, 290, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 144, 80, 147, 33,$BS_FLAT)
$hImage= _GUIImageList_Create(20, 20, 5, 1, 0)
_GUIImageList_AddIcon($hImage,"OneKey.exe", 0, True)
_GUICtrlButton_SetImageList(-1, $hImage)
GUISetState(@SW_SHOW) 
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 4金钱 +95 贡献 +26 收起 理由
水木子 + 20 厉害!学习啦!
131738 + 50 + 20
hzxymkb + 10 + 5 谢谢您
afan + 15 + 1

查看全部评分

发表于 2010-1-4 14:24:53 | 显示全部楼层
本帖最后由 lchl0588 于 2010-1-4 14:55 编辑

回复 2# 顽固不化
呵呵,我也有一段代码:
#include <GuiButton.au3>
#include <GuiImageList.au3>
#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 501, 290, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 144, 80, 147, 33,$BS_FLAT)
$hImage= _GUIImageList_Create(20, 20, 5, 1, 0)
_GUIImageList_AddIcon($hImage,"d:\Program Files\TTPlayer\TTPlayer.exe", 0, True)
_GUICtrlButton_SetImageList(-1, $hImage)
GUISetState(@SW_SHOW) 
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
不过,我的千千静听在D盘下

呵呵,经测试,只改下
_GUIImageList_AddIcon($hImage,"shell32.dll", 1, True)
这段已可,把1改为EXE已有的图标位置(参下图)   shell32.dll   可以改为:d:\Program Files\TTPlayer\TTPlayer.exe可以是完整的路径,或跟顽固一样,但有点:顽固的文件必与代码在同一目录下才能运行哦
如下图是顽固的作法:


其实还有一个帖子:
点此进入另一帖

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 3金钱 +95 贡献 +26 收起 理由
131738 + 50 + 20
afan + 20 + 1
hzxymkb + 25 + 5 谢谢您呀!

查看全部评分

 楼主| 发表于 2010-1-4 15:03:03 | 显示全部楼层
回复 3# lchl0588

我以为图标的排列是从1开始的!
没想到是0开始的!
谢谢了!
发表于 2010-1-26 23:32:15 | 显示全部楼层
精品!学习了~~
发表于 2010-3-7 17:21:47 | 显示全部楼层
顶你。这个经典。
发表于 2010-3-8 18:19:46 | 显示全部楼层
无意之中来到此地,哈哈!!!果然读万卷书不如走万里路啊!
发表于 2012-3-5 21:53:07 | 显示全部楼层
好东西呀,,,学习了
发表于 2012-3-9 13:41:20 | 显示全部楼层
不错,好东西,我用了。
发表于 2012-3-31 19:51:52 | 显示全部楼层
留足备用 谢谢分享
发表于 2012-9-21 00:08:27 | 显示全部楼层
学习了,现在正需要
发表于 2014-4-16 20:44:51 | 显示全部楼层
谢谢,学习了。
发表于 2015-9-16 07:04:26 | 显示全部楼层
有用正需要
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-3 18:34 , Processed in 0.081263 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表