wk198 发表于 2010-3-31 15:18:34

gui界面中 tab 控件如何把 图片设置到上面

$Tab1 = GUICtrlCreateTab(8, 80, 473, 513)
$TabSheet1 = GUICtrlCreateTabItem(" 哈哈")
_GUICtrlTab_SetItemImage($Tab1, 0, 1)

这样有 tab 加载图标 默认是显示在 文字的左边

我想设置到 文字的上面 如何 扩张样式呢

wk198 发表于 2010-4-2 01:20:13

......................

zhangla 发表于 2010-4-2 13:03:18

只好想其它办法了。

水木子 发表于 2010-4-2 13:32:28

本帖最后由 水木子 于 2010-4-2 14:00 编辑

标签控件倒是没有试过,不过咱这儿有个例子,楼主不妨看看,希望能有启发。#include <GuiButton.au3>
#include <GuiImageList.au3>

GUICreate("设置按钮图标", 560, 100)
$But1 = GUICtrlCreateButton("图标靠左", 10, 20, 100, 60, $BS_FLAT)
_SetIcon(-1, 'shell32.dll', 22, 0, 20, 20)

$But2 = GUICtrlCreateButton("图标靠右", 120, 20, 100, 60, $BS_FLAT)
_SetIcon(-1, 'shell32.dll', 23, 1)

$But3 = GUICtrlCreateButton("图标靠上", 230, 20, 100, 60, $BS_FLAT)
_SetIcon(-1, 'shell32.dll', 24, 2, 30, 30)

$But4 = GUICtrlCreateButton("图标靠下", 340, 20, 100, 60, $BS_FLAT)
_SetIcon(-1, 'shell32.dll', 25, 3, 35, 35)

$But5 = GUICtrlCreateButton("图标居中", 450, 20, 100, 60, $BS_FLAT)
_SetIcon(-1, 'shell32.dll', 26, 4, 40, 40)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit

        EndSwitch
WEnd

Func _SetIcon($hWnd, $sFile, $iIndex = 0, $nAlign = 0, $iWidth = 25, $iHeight = 25) ;控件句柄, 图标图像的路径, 图标索引, 图标在控件中的位置, 图标宽度, 图标高度
        $hImage1 = _GUIImageList_Create($iWidth, $iHeight, 5, 1, 0) ;创建图像列表控件
        _GUIImageList_AddIcon($hImage1, $sFile, $iIndex, True) ;向图像列表添加图标
        _GUICtrlButton_SetImageList($hWnd, $hImage1, $nAlign) ;分配一个图像列表到按钮控件,$nAlign 是图标位置参数
EndFunc   ;==>_SetIcon

wk198 发表于 2010-4-5 19:55:23

_GUICtrlButton_SetImageList($hWnd, $hImage1, $nAlign)
他是靠$nAlign 来设置图标位置
而 _GUICtrlTab_SetImageList($hWnd, $hImage)
只有2个参数不带位置的参数
我看过了

wk198 发表于 2010-4-5 19:55:43

不过还是谢谢你的跟贴

wk198 发表于 2010-4-5 19:58:12

_GUICtrlTab_SetItemImage($hWnd, $iIndex, $iImage)

同样不带位置参数

afan 发表于 2010-4-5 20:01:15

标签横排的话设置图标到上面应该不好看吧,竖排的话可以看看GUICtrlCreateTab的样式

wk198 发表于 2010-4-7 01:12:46

谢谢
想图片在上 文字在下

干脆自己ps做个图片包含文字

然后tab 显示图片 等同于的效果 就是文字在下
呵呵
页: [1]
查看完整版本: gui界面中 tab 控件如何把 图片设置到上面