找回密码
 加入
搜索
查看: 10721|回复: 26

[AU3基础] 添加图标到Button按钮的问题?

 火... [复制链接]
发表于 2011-1-11 12:37:03 | 显示全部楼层 |阅读模式
本帖最后由 19377708 于 2011-1-12 22:10 编辑

不加载皮肤时图标正常。

加载皮肤后不能显示图标,不管用那个皮肤和DLL都出现一样的情况.

利用GUICtrlSetImage加载图标,可以正常显示,
但不能将图标显示到按钮顶部,文字显示到按钮底部,自己研究了N久找不到解决方法。非常纠结中。望各位高手指点下。在这里先谢谢各位了。思路,能将图标添加到按钮中,图标显示到按钮顶部。文字显示到按钮底部。并能同时加载皮肤。能将按钮透明更好,就是只显示按钮的图标和文字。边框不显示、

_GUICtrlButton_SetImageList 添加图标代码
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiImageList.au3>
#Include <GuiButton.au3>
$aero = @TempDir&"\qq2008.she"
$skin = @TempDir&"\Skin.dll"
If Not FileExists($aero) Then FileInstall("qq2008.she",$aero,1) 
If Not FileExists($skin) Then FileInstall("Skin.dll",$skin,1)
Skin($aero);不加载皮肤程序图标可正常显示,加载皮肤后图标不能正常显示,不管用那个皮肤和DLL都出现一样的情况
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("添加图标到按钮", 372, 108, 384, 345)
$Button1 = GUICtrlCreateButton("我的电脑", 16, 16, 75, 73);BitOR($BS_ICON,$BS_BITMAP,$BS_FLAT )
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll",-16, True),2,-1,12)
$Button2 = GUICtrlCreateButton("网上邻居", 104, 16, 75, 73)
_GUICtrlButton_SetImageList($Button2, _GetImageListHandle("shell32.dll",-18, True),2,-1,12)
$Button3 = GUICtrlCreateButton("回收站", 192, 16, 75, 73)
_GUICtrlButton_SetImageList($Button3, _GetImageListHandle("shell32.dll",-32, True),2,-1,12)
$Button4 = GUICtrlCreateButton("控制面板", 282, 16, 75, 73)
_GUICtrlButton_SetImageList($Button4, _GetImageListHandle("shell32.dll",-22, True),2,-1,12)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        ShellExecute("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
                Case $Button2
                        ShellExecute("::{208D2C60-3AEA-1069-A2D7-08002B30309D}")
                Case $Button3
                        ShellExecute("::{645FF040-5081-101B-9F08-00AA002F954E}")
                Case $Button4
                        ShellExecute("control")
        EndSwitch
WEnd

; using image list to set 1 image and have text on button
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
        Local $iSize = 16
        If $fLarge Then $iSize = 32
        
        Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
        If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
                _GUIImageList_AddBitmap($hImage, $sFile)
        Else
                _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
        EndIf
        Return $hImage
EndFunc   ;==>_GetImageListHandle

;皮肤函数
Func Skin($She)
        $Dll = DllOpen($skin)
        DllCall($Dll, "int", "SkinH_AttachEx", "str",$She, "str", "benkel")
        DllCall($Dll, "int", "SkinH_SetAero", "int",0);0=不透明标题栏,1=透明标题栏
EndFunc   ;==>Skin
GUICtrlSetImage 添加图标代码
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$aero = @TempDir&"\qq2008.she"
$skin = @TempDir&"\Skin.dll"
If Not FileExists($aero) Then FileInstall("qq2008.she",$aero,1) 
If Not FileExists($skin) Then FileInstall("Skin.dll",$skin,1)
Skin($aero);不加载皮肤程序图标可正常显示,加载皮肤后图标不能正常显示,不管用那个皮肤和DLL都出现一样的情况
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("添加图标到按钮", 372, 108, 384, 345)
$Button1 = GUICtrlCreateButton("我的电脑", 16, 16, 75, 73,0x0040);BitOR($BS_ICON,$BS_BITMAP,$BS_FLAT )
GUICtrlSetImage(-1,"shell32.dll",-16,1)
$Button2 = GUICtrlCreateButton("网上邻居", 104, 16, 75, 73,0x0040)
GUICtrlSetImage(-1,"shell32.dll",-18)
$Button3 = GUICtrlCreateButton("回收站", 192, 16, 75, 73,0x0040)
GUICtrlSetImage(-1,"shell32.dll",-32)
$Button4 = GUICtrlCreateButton("控制面板", 282, 16, 75, 73,0x0040)
GUICtrlSetImage(-1,"shell32.dll",-22)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        ShellExecute("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
                Case $Button2
                        ShellExecute("::{208D2C60-3AEA-1069-A2D7-08002B30309D}")
                Case $Button3
                        ShellExecute("::{645FF040-5081-101B-9F08-00AA002F954E}")
                Case $Button4
                        ShellExecute("control")
        EndSwitch
WEnd

;皮肤函数
Func Skin($She)
        $Dll = DllOpen($skin)
        DllCall($Dll, "int", "SkinH_AttachEx", "str",$She, "str", "benkel")
        DllCall($Dll, "int", "SkinH_SetAero", "int",0);0=不透明标题栏,1=透明标题栏
EndFunc   ;==>Skin
皮肤下载地址:http://u.115.com/file/f53b1d20b9#
添加图标到按钮.rar

本帖子中包含更多资源

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

×
发表于 2011-1-11 16:35:44 | 显示全部楼层
http://www.autoitx.com/thread-12980-1-1.html
不知道楼主是不是要这个
发表于 2011-1-11 17:15:57 | 显示全部楼层
这个哥们 威望-10 点 金钱21 块 贡献-57 分
 楼主| 发表于 2011-1-11 18:25:37 | 显示全部楼层
本帖最后由 19377708 于 2011-1-11 18:26 编辑

回复 2# netegg
情况还是一样,谢谢你

本帖子中包含更多资源

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

×
发表于 2011-1-11 21:26:07 | 显示全部楼层
回复 4# 19377708
试试看先加皮肤再加图标呢
发表于 2011-1-12 08:54:44 | 显示全部楼层
加载皮肤问题多得很哦 。我也遇到过。很无赖!
发表于 2011-1-12 10:11:16 | 显示全部楼层
本帖最后由 3mile 于 2011-1-12 10:24 编辑

回复 1# 19377708
试试这个。应该可以解决问题

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiImageList.au3>
#Include <GuiButton.au3>
$aero = @ScriptDir&"\qq2010.she"
$skin = @ScriptDir&"\Skin.dll"
If Not FileExists($aero) Then FileInstall("aero.she",$aero,1) 
If Not FileExists($skin) Then FileInstall("Skin.dll",$skin,1)
;Skin($aero);不加载皮肤程序图标可正常显示,加载皮肤后图标不能正常显示,不管用那个皮肤和DLL都出现一样的情况
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("添加图标到按钮", 372, 108, 384, 345)
$Button1 = GUICtrlCreateButton("我的电脑", 16, 16, 75, 73);BitOR($BS_ICON,$BS_BITMAP,$BS_FLAT )
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll",-16, True),2,-1,12)
;Global $h_button1=GUICtrlGetHandle($Button1)
$Button2 = GUICtrlCreateButton("网上邻居", 104, 16, 75, 73)
_GUICtrlButton_SetImageList($Button2, _GetImageListHandle("shell32.dll",-18, True),2,-1,12)
$Button3 = GUICtrlCreateButton("回收站", 192, 16, 75, 73)
_GUICtrlButton_SetImageList($Button3, _GetImageListHandle("shell32.dll",-32, True),2,-1,12)
$Button4 = GUICtrlCreateButton("控制面板", 282, 16, 75, 73)
_GUICtrlButton_SetImageList($Button4, _GetImageListHandle("shell32.dll",-22, True),2,-1,12)
Skin($aero)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        ShellExecute("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
                Case $Button2
                        ShellExecute("::{208D2C60-3AEA-1069-A2D7-08002B30309D}")
                Case $Button3
                        ShellExecute("::{645FF040-5081-101B-9F08-00AA002F954E}")
                Case $Button4
                        ShellExecute("control")
        EndSwitch
WEnd

; using image list to set 1 image and have text on button
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
        Local $iSize = 16
        If $fLarge Then $iSize = 32
        
        Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
        If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
                _GUIImageList_AddBitmap($hImage, $sFile)
        Else
                _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
        EndIf
        Return $hImage
EndFunc   ;==>_GetImageListHandle

;皮肤函数
Func Skin($She)
        $Dll = DllOpen($skin)
        DllCall($Dll, "int", "SkinH_AttachEx", "str",$She, "str", "benkel")
        DllCall($Dll, "int", "SkinH_SetAero", "int",0);0=不透明标题栏,1=透明标题栏
                DllCall($Dll, "int", "SkinH_DetachEx", "int",GUICtrlGetHandle($Button1));此控件不加载图标
                DllCall($Dll, "int", "SkinH_DetachEx", "int",GUICtrlGetHandle($Button2));此控件不加载图标
                DllCall($Dll, "int", "SkinH_DetachEx", "int",GUICtrlGetHandle($Button3));此控件不加载图标
                DllCall($Dll, "int", "SkinH_Map", "int",GUICtrlGetHandle($Button4),"int",3002);此控件为位图按钮,代码3002
                DllCall($Dll, "int", "SkinH_SetWindowsAlpha", "int",GUICtrlGetHandle($Button4),"int",1);设置控件透明?
EndFunc   ;==>Skin

本帖子中包含更多资源

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

×
 楼主| 发表于 2011-1-12 10:24:34 | 显示全部楼层
回复 7# 3mile


问题还是存在,谢谢你的回答

本帖子中包含更多资源

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

×
发表于 2011-1-12 10:26:21 | 显示全部楼层
回复 8# 19377708
用楼上的代码试试,我这里已经完全正常。
 楼主| 发表于 2011-1-12 10:30:19 | 显示全部楼层
回复 9# 3mile


    嗯嗯。完全正常,谢谢,请问,能否将按钮透明呢?不显示按钮边框,只显示图标?
发表于 2011-1-12 10:44:34 | 显示全部楼层
这个哥们 威望-10 点 金钱21 块 贡献-57 分
gzh888666 发表于 2011-1-11 17:15

我也觉得奇怪!

刚刚翻阅了这哥们儿的回帖记录,原来这哥们儿有严重的灌水刷分行为,所以才被扣成这样的。

再次奉劝一句,“若要人不知,除非己莫为”
发表于 2011-1-12 10:50:02 | 显示全部楼层
如果是原创还是鼓励一下,否则.....................
发表于 2011-1-12 11:24:16 | 显示全部楼层
我也觉得奇怪!

刚刚翻阅了这哥们儿的回帖记录,原来这哥们儿有严重的灌水刷分行为,所以才被扣成这样 ...
水木子 发表于 2011-1-12 10:44


呵呵,你查他的案底了.
发表于 2011-1-12 14:16:46 | 显示全部楼层
回复 11# 水木子

哇!好久不见水哥了!
发表于 2011-1-12 14:18:14 | 显示全部楼层
回复 11# 水木子

不被禁言已经很不错咯!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-9 05:45 , Processed in 0.084109 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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