xtanxin 发表于 2010-1-11 10:45:40

1. 2. 按钮如何实现上面是图标,下面是文字的效果?是另一个控件还是需要在做特殊处理?

如同windows资源管理器浏览文件的图标

ceoguang 发表于 2010-1-11 11:15:16

帮助里的#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, $rdo, $chk, $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 = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetImageList($btn, $hImage)

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

    $chk = GUICtrlCreateCheckbox("Check Button1", 260, 10, 120, 25)
    _GUICtrlButton_SetImageList($chk, $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

xtanxin 发表于 2010-1-11 11:55:22

给说实现流程,我自己琢磨,在不行了,在给代码.
差的是经验和对AU3的特性不足够了解,俺求代码的时候,您在给.免的培养我不良习惯.呵呵.主要是怕大家太累.

xtanxin 发表于 2010-1-11 16:14:09

刚刚有时间看,是在帮助,在UDF里面.

我对GUI还是很弱呀.用的少多了.
页: [1]
查看完整版本: 1. 2. 按钮如何实现上面是图标,下面是文字的效果?是另一个控件还是需要在做特殊处理?