工具栏中的图标怎样修改
本帖最后由 jycel 于 2009-6-20 18:41 编辑如图:先还是为是普通按钮做成的!在帮助中找到了很多TOOLBAR的函数,里面全是英文,没有找到可修改图标的地方!还有个问题就是对中文不完全支持,只显示一半,不会又得转换一次?#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
Opt('MustDeclareVars', 1)
$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hGUI, $hToolbar, $aStrings
Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp
; Create GUI
$hGUI = GUICreate("Toolbar", 400, 300)
$hToolbar = _GUICtrlToolbar_Create ($hGUI)
GUISetState()
; Add standard system bitmaps
_GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
; Add strings
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&中华人民共和国中华人民共和国")
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&Open")
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&Save")
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&Help")
; Add buttons
_GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW, $aStrings)
_GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN, $aStrings)
_GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE, $aStrings)
_GUICtrlToolbar_AddButtonSep ($hToolbar)
_GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP, $aStrings)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main 知道的请指点下!谢谢! 编译的时候,是什么图标就变什么图标拉 应该有方法的 效果图:
#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
_Main()
Func _Main()
Local $hGUI, $hToolbar
$custombmp1 = "vista.bmp"
$custombmp2 = "butterfly.bmp"
$custombmp3= "guest.bmp"
$custombmp4 = "ball.bmp"
$hGUI = GUICreate("Toolbar工具栏自定义图标示例by lynfr8", 400, 300)
$hToolbar = _GUICtrlToolbar_Create ($hGUI)
GUISetState()
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp1)
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp2)
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp3)
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp4)
_GUICtrlToolbar_SetBitmapSize($hToolbar, 20, 20)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 0)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 1)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 2)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 3)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc
至于支持中文的问题
试试在27行位置加入
_GUICtrlToolbar_SetUnicodeFormat() #include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#Include <GuiToolBar.au3>
Opt('MustDeclareVars', 1)
$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hGUI, $fUnicode, $hToolbar, $aStrings
Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp
; Create GUI
$hGUI = GUICreate("Toolbar", 800, 600)
$hToolbar = _GUICtrlToolbar_Create ($hGUI)
GUISetState()
; Add standard system bitmaps
_GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
$fUnicode = _GUICtrlToolbar_GetUnicodeFormat($hToolbar)
_GUICtrlToolbar_SetUnicodeFormat($hToolbar, Not $fUnicode)
; Add strings
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&中华人民共和国中华人民共和国")
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&Open")
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&Save")
$aStrings = _GUICtrlToolbar_AddString ($hToolbar, "&Help")
; Add buttons
_GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW, $aStrings)
_GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN, $aStrings)
_GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE, $aStrings)
_GUICtrlToolbar_AddButtonSep ($hToolbar)
_GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP, $aStrings)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_Main 刚上网,马上试下!谢谢指点哈! 更换图片和中文都搞定了,图片怎么一直对不齐!_GUICtrlToolbar_AddButton 帮助中都试了下没效果!#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
_Main()
Func _Main()
Local $hGUI, $hToolbar,$fUnicode
$custombmp1 = "1.bmp"
$custombmp2 = "2.bmp"
$custombmp3= "3.bmp"
$custombmp4 = "4.bmp"
$hGUI = GUICreate("Toolbar工具栏自定义图标示例by lynfr8", 400, 300)
$hToolbar = _GUICtrlToolbar_Create ($hGUI)
GUISetState()
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp1)
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp2)
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp3)
$Bitmap = _GUICtrlToolbar_LoadBitmap($hToolbar,$custombmp4)
;_GUICtrlToolbar_LoadImages($hToolbar, $IDB_STD_LARGE_COLOR)
$fUnicode = _GUICtrlToolbar_GetUnicodeFormat($hToolbar)
_GUICtrlToolbar_SetUnicodeFormat($hToolbar, Not $fUnicode)
$custombmp1 = _GUICtrlToolbar_AddString ($hToolbar, "&1号键")
$custombmp2 = _GUICtrlToolbar_AddString ($hToolbar, "&2号键")
$custombmp3 = _GUICtrlToolbar_AddString ($hToolbar, "&3号键")
$custombmp4 = _GUICtrlToolbar_AddString ($hToolbar, "&4号键")
_GUICtrlToolbar_SetBitmapSize($hToolbar, 48, 20)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 0,$custombmp1)
_GUICtrlToolbar_AddButtonSep ($hToolbar)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 1,$custombmp2)
_GUICtrlToolbar_AddButtonSep ($hToolbar)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 2,$custombmp3)
_GUICtrlToolbar_AddButtonSep ($hToolbar)
_GUICtrlToolbar_AddButton ($hToolbar, $Bitmap, 3,$custombmp4)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc 48*48的图像看起太小了,不知道那儿可以调整!我再找找,知道的也请再指下 本帖最后由 jycel 于 2009-6-21 19:10 编辑
不加这一句_GUICtrlToolbar_SetBitmapSize($hToolbar, 48, 20)就解决了不对齐的问题,但图像大小还不知道怎么来处理!
页:
[1]