GUI上能否做出左图右文的按钮
本帖最后由 五猫橙 于 2009-10-12 19:09 编辑就是一个按钮上.左边是一个小图标.右边是文字
如果可以的话..怎么做呃...THX $BS_BITMAP
$BS_ICON GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 22)
那就只有图没有文了...我想要他们共存.. 这个能帮到你
_GUICtrlButton_GetImageList 4楼厉害,哎,很多UDF都还是英文的帮助,看不懂。却是郁闷哦。。 本帖最后由 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, "宋体") 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! 嗯.不错..LS的例子收下了.. 本帖最后由 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, $rdo, $chk, $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
页:
[1]