找回密码
 加入
搜索
查看: 3565|回复: 7

怎么在GUI 窗口下的按钮控件里加入图片和文字

[复制链接]
发表于 2008-11-28 21:53:23 | 显示全部楼层 |阅读模式
就是在GUICtrlCreateButton下同时显示图片和文字2个结合,请高人帮助我下,
发表于 2008-11-28 22:12:52 | 显示全部楼层
帮助里就有


#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
 Local $hImage, $y = 70, $iIcon = 125, $btn[6], $rdo[6], $chk[6], $hImageSmall
 
 GUICreate("Buttons", 510, 400)
 GUISetState()

 $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
 For $x = 6 To 11
 _GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
 Next

 $hImageSmall = _GUIImageList_Create(16, 16, 5, 3, 6)
 For $x = 6 To 11
 _GUIImageList_AddIcon($hImageSmall, "shell32.dll", $x)
 Next

 $btn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
 _GUICtrlButton_SetImageList($btn[0], $hImage)

 $rdo[0] = GUICtrlCreateRadio("Radio Button1", 120, 10, 120, 25)
 _GUICtrlButton_SetImageList($rdo[0], $hImageSmall)

 $chk[0] = GUICtrlCreateCheckbox("Check Button1", 260, 10, 120, 25)
 _GUICtrlButton_SetImageList($chk[0], $hImageSmall)


 For $x = 1 To 5
 $btn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
 _GUICtrlButton_SetImageList($btn[$x], _GetImageListHandle("shell32.dll", $iIcon + $x, True), $x)
 $rdo[$x] = GUICtrlCreateRadio("Radio Button" & $x + 1, 120, $y, 120, 25)
 _GUICtrlButton_SetImageList($rdo[$x], _GetImageListHandle("shell32.dll", $iIcon + $x), $x)
 $chk[$x] = GUICtrlCreateCheckbox("Check Button" & $x + 1, 260, $y, 120, 25)
 _GUICtrlButton_SetImageList($chk[$x], _GetImageListHandle("shell32.dll", $iIcon + $x), $x)
 $y += 60
 Next
 
 While 1
 Switch GUIGetMsg()
 Case $GUI_EVENT_CLOSE
 ExitLoop
 EndSwitch
 WEnd

 Exit
EndFunc   ;==>_Main

; 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

 楼主| 发表于 2008-12-6 17:14:47 | 显示全部楼层
能不能只举个例子,本人有点笨,
跟这个一样,就写一个例子,别写太多的按钮,还是很感谢上面那个例子,但是你的例子太多了,不知道什么意思,如果能分开写那就很明白了


[ 本帖最后由 lufo1989 于 2008-12-6 17:25 编辑 ]

本帖子中包含更多资源

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

×
发表于 2008-12-6 18:19:11 | 显示全部楼层
唉~~~英文版的帮助~~~~~~~同求~~~~
发表于 2010-6-4 09:09:14 | 显示全部楼层
又学到新知识了!
发表于 2010-6-4 12:02:53 | 显示全部楼层
搜索一下就知道啦很多例子
发表于 2014-5-6 09:33:10 | 显示全部楼层
雷锋精神传天下!谢谢分享!
发表于 2014-12-3 15:06:24 | 显示全部楼层
感谢分享,学习了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 10:15 , Processed in 0.123337 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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