本帖最后由 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 |