找回密码
 加入
搜索
查看: 1750|回复: 8

GUI上能否做出左图右文的按钮

[复制链接]
发表于 2009-10-12 12:14:27 | 显示全部楼层 |阅读模式
本帖最后由 五猫橙 于 2009-10-12 19:09 编辑

就是一个按钮上.左边是一个小图标.右边是文字
如果可以的话..怎么做呃...THX
发表于 2009-10-12 12:45:32 | 显示全部楼层
$BS_BITMAP
$BS_ICON
 楼主| 发表于 2009-10-12 14:10:03 | 显示全部楼层
GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 22)

那就只有图没有文了...我想要他们共存..
发表于 2009-10-12 14:21:59 | 显示全部楼层
这个能帮到你
_GUICtrlButton_GetImageList
发表于 2009-10-12 18:31:53 | 显示全部楼层
4楼厉害,哎,很多UDF都还是英文的帮助,看不懂。却是郁闷哦。。
发表于 2009-10-12 18:41:42 | 显示全部楼层
本帖最后由 rho123 于 2009-10-12 18:43 编辑
#include <GuiButton.au3>
$Button1 = GUICtrlCreateButton("添加商品", 5, 8, 89, 38,  $BS_FLAT)
$hImage1 = _GUIImageList_Create(20, 20, 5, 1, 0)
_GUIImageList_AddIcon($hImage1, "shell32.dll", 165, True)
_GUICtrlButton_SetImageList(-1, $hImage1)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
$Button2 = GUICtrlCreateButton("商品变更", 105, 8, 89, 38, $BS_FLAT)
$hImage2 = _GUIImageList_Create(20, 20, 5, 1, 0)
_GUIImageList_AddIcon($hImage2, "shell32.dll", 166, True)
_GUICtrlButton_SetImageList(-1, $hImage2)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
$Button3 = GUICtrlCreateButton("收入统计", 205, 8, 89, 38, $BS_FLAT)
$hImage3 = _GUIImageList_Create(20, 20, 5, 1, 0)
_GUIImageList_AddIcon($hImage3, "shell32.dll", 167, True)
_GUICtrlButton_SetImageList(-1, $hImage3)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
$Button4 = GUICtrlCreateButton("资金变更", 304, 8, 89, 38, $BS_FLAT)
$hImage4 = _GUIImageList_Create(20, 20, 5, 1, 0)
_GUIImageList_AddIcon($hImage4, "shell32.dll", 169, True)
_GUICtrlButton_SetImageList(-1, $hImage4)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")

本帖子中包含更多资源

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

×

评分

参与人数 1金钱 +10 收起 理由
五猫橙 + 10

查看全部评分

 楼主| 发表于 2009-10-12 19:08:45 | 显示全部楼层
10# heavenm

在前面加上:
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#Include <GuiImageList.au3>
$Form1 = GUICreate("Form1", 633, 446, 604, 350)
后面加上:
GUISetState(@SW_SHOW)
While 1
        Sleep(300)
WEnd

非常感谢rho!
 楼主| 发表于 2009-10-12 21:57:50 | 显示全部楼层
嗯.不错..LS的例子收下了..
发表于 2009-10-13 13:25:27 | 显示全部楼层
本帖最后由 jycel 于 2009-10-13 13:31 编辑

一个是调用系统一个是自定义的!
注意:在使用时不能给按钮后面加背景色,我测试时添了显示不了!鼠标指针可以……
如图:


#Include <GuiImageList.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
Local $hImage, $y = 70, $iIcon = 3, $btn[6], $rdo[6], $chk[6], $hImageSmall
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("图标按钮测试", 633, 454, 192, 114)
$Button1 = GUICtrlCreateButton("退出", 112, 112, 337, 65)
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll", $iIcon , True), 0,2,2)
$Button2 = GUICtrlCreateButton("退出", 112, 212, 337, 35)
 ;
 $hImage = _GUIImageList_Create(32, 32, 6, 3, 6,True)
 _GUIImageList_AddIcon($hImage, @ScriptDir&"\1.ico",0,True)
 _GUICtrlButton_SetImageList($Button2,  $hImage, 0,2,2)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        EndSwitch
WEnd
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

本帖子中包含更多资源

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

×
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-4 14:51 , Processed in 0.085466 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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