求助!为什么工具栏的图标不能显示?【已解决】
本帖最后由 xms77 于 2012-2-27 23:19 编辑RT,图标文件打包了。
#include-once
#include <WindowsConstants.au3>
#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <Constants.au3>
#Include <GuiImageList.au3>
Local Enum $idOpen=1000 , $idSave,$idMDconfig, $idHDfactor,$idMCconfig,$idclose
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\桌面\Main_Form.kxf
$Main_Form = GUICreate("Low Cost Gramload Tester Program (Ver2.5A)", 810, 571, 192, 124,$WS_OVERLAPPEDWINDOW)
$Menu_File = GUICtrlCreateMenu("&File")
$Menu_File_New = GUICtrlCreateMenuItem("New", $Menu_File)
$Menu_File_Open = GUICtrlCreateMenuItem("Open"&@TAB&"F3", $Menu_File)
$Menu_File_Close = GUICtrlCreateMenuItem("Close", $Menu_File)
GUICtrlSetState(-1, $GUI_Disable)
GUICtrlCreateMenuItem("", $Menu_File)
$Menu_File_Save = GUICtrlCreateMenuItem("Save", $Menu_File)
$Menu_File_SaveAs = GUICtrlCreateMenuItem("Save As", $Menu_File)
GUICtrlCreateMenuItem("", $Menu_File)
$Menu_File_ModelConfig = GUICtrlCreateMenuItem("Model Config"&@TAB&"F4", $Menu_File)
GUICtrlSetState(-1, $GUI_Disable)
$Menu_File_HDConfig = GUICtrlCreateMenuItem("HD Config", $Menu_File)
GUICtrlSetState(-1, $GUI_Disable)
$Menu_File_MachineConfig = GUICtrlCreateMenuItem("Machine Config "&@TAB&"F5", $Menu_File)
GUICtrlCreateMenuItem("", $Menu_File)
$Menu_File_Exit = GUICtrlCreateMenuItem("Exit"&@TAB&"Alt+F4", $Menu_File)
$Menu_Setup = GUICtrlCreateMenu("&Setup")
$Menu_Setup_Diagnostic = GUICtrlCreateMenuItem("Diagnostic...", $Menu_Setup)
GUICtrlSetState(-1, $GUI_Disable)
$Menu_Setup_GoUp = GUICtrlCreateMenuItem("Go Up", $Menu_Setup)
GUICtrlSetState(-1, $GUI_Disable)
$Menu_Setup_Download = GUICtrlCreateMenuItem("Download", $Menu_Setup)
GUICtrlSetState(-1, $GUI_Disable)
$Menu_Setup_ChangePassword = GUICtrlCreateMenu("Change Password ...", $Menu_Setup)
$Menu_Setup_PRMPassword = GUICtrlCreateMenuItem("PRM Mode ...", $Menu_Setup_ChangePassword)
$Menu_Setup_RWKPassword = GUICtrlCreateMenuItem("RWK Mode ...", $Menu_Setup_ChangePassword)
$Menu_Set_ENGPassword = GUICtrlCreateMenuItem("ENG Mode ...", $Menu_Setup_ChangePassword)
GUICtrlCreateMenuItem("", $Menu_Setup_ChangePassword)
$Menu_Setup_Technical = GUICtrlCreateMenuItem("Technical ...", $Menu_Setup_ChangePassword)
$Menu_Setup_Supervisor = GUICtrlCreateMenuItem("Supervisor ...", $Menu_Setup_ChangePassword)
$Menu_Setup_Engineer = GUICtrlCreateMenuItem("Engineer ...", $Menu_Setup_ChangePassword)
$Menu_Production = GUICtrlCreateMenu("&Prduction")
GUICtrlSetState(-1, $GUI_Disable)
$Menu_Production_Employee = GUICtrlCreateMenuItem("Employee Number ...", $Menu_Production)
$Menu_Production_SBR = GUICtrlCreateMenuItem("SBR Number ...", $Menu_Production)
$Menu_Production_Fixture = GUICtrlCreateMenuItem("Fixtrue Number ...", $Menu_Production)
$Menu_Production_TestMode = GUICtrlCreateMenuItem("Test Mode", $Menu_Production)
$Menu_Production_PRMBuild = GUICtrlCreateMenuItem("Prime Build ..."&@TAB&"F9", $Menu_Production)
$Menu_Production_RWKBuild = GUICtrlCreateMenuItem("Rework Build ..."&@TAB&"F10", $Menu_Production)
$Menu_Production_ENGBuild = GUICtrlCreateMenuItem("Engineer Build ..."&@TAB&"F11", $Menu_Production)
$Menu_Windows = GUICtrlCreateMenu("&Windows")
$MenuItem3 = GUICtrlCreateMenuItem("Cascade", $Menu_Windows)
GUICtrlSetState(-1, $GUI_Disable)
$MenuItem2 = GUICtrlCreateMenuItem("Tile", $Menu_Windows)
GUICtrlSetState(-1, $GUI_Disable)
$MenuItem4 = GUICtrlCreateMenuItem("Arrange Icon", $Menu_Windows)
GUICtrlSetState(-1, $GUI_Disable)
$MenuItem1 = GUICtrlCreateMenuItem("Minimize All", $Menu_Windows)
GUICtrlSetState(-1, $GUI_Disable)
$Menu_Help = GUICtrlCreateMenu("&Help")
$Menu_Help_About = GUICtrlCreateMenuItem("About ..."&@TAB&"F1", $Menu_Help)
GUISetIcon("C:\Lc_gram\1.ico", -1)
Dim $Main_Form_AccelTable = [["{F3}", $Menu_File_Open],["{F4}", $Menu_File_ModelConfig],["{F5}", $Menu_File_MachineConfig],["!{F4}", $Menu_File_Exit],["{F9}", $Menu_Production_PRMBuild],["{F10}", $Menu_Production_RWKBuild],["{F11}", $Menu_Production_ENGBuild],["{F1}", $Menu_Help_About]]
GUISetAccelerators($Main_Form_AccelTable)
$hToolbar = _GUICtrlToolbar_Create($Main_Form,$TBSTYLE_FLAT)
$hToolBar_Image = _GUIImageList_Create(32, 32, 5)
_GUIImageList_AddIcon($hToolBar_Image, @SystemDir & "\images\open.ico", 0)
_GUIImageList_AddIcon($hToolBar_Image, @SystemDir & "\images\save.ico", 1)
_GUIImageList_AddIcon($hToolBar_Image, @SystemDir & "\images\md_config.ico", 2)
_GUIImageList_AddIcon($hToolBar_Image, @SystemDir & "\images\hd_factor.ico", 3)
_GUIImageList_AddIcon($hToolBar_Image, @SystemDir & "\images\mc_config", 4)
_GUIImageList_AddIcon($hToolBar_Image, @SystemDir & "\images\close.ico", 5)
_GUICtrlToolbar_SetImageList($hToolBar, $hToolBar_Image)
; Add buttons
_GUICtrlToolbar_AddButton($hToolBar, $idopen, 0)
;_GUICtrlToolbar_EnableButton ($hToolbar, $idOpen, False)
_GUICtrlToolbar_AddButton($hToolbar, $idSave, 1)
_GUICtrlToolbar_AddButton($hToolbar, $idMDconfig,2)
_GUICtrlToolbar_AddButton($hToolbar, $idHDfactor,3)
_GUICtrlToolbar_AddButton($hToolbar, $idMCconfig,4)
_GUICtrlToolbar_AddButton($hToolbar, $idclose,5)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg
Case $GUI_EVENT_CLOSE
If $nMsg = $Main_Form Then
GUIDelete($Main_Form)
Exit
EndIf
Case $Menu_Help_About
MsgBox(0,"About","123")
;GUISetState($Main_Form,$GUI_Enable)
;Case $Help_GUI_Btn
EndSwitch
WEnd
@SystemDir? 本帖最后由 afan 于 2012-2-27 23:12 编辑
67 - 73 改成如下,大红大绿的,美美嘀… ^ ^$hToolBar_Image = _GUIImageList_Create(32, 32, 5, 3)
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\open.ico", 0, 1)
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\save.ico", 0, 1)
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\md_config.ico", 0, 1)
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\hd_factor.ico", 0, 1)
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\mc_config.ico", 0, 1)
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\close.ico", 0, 1)
@ScriptDir 改不改无所谓,在哪就哪,关键是后面的参数问题。 _GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\open.ico")
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\save.ico")
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\md_config.ico")
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\hd_factor.ico")
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\mc_config.ico")
_GUIImageList_AddIcon($hToolBar_Image, @ScriptDir & "\images\close.ico")
注意你的mc_config扩展名都没有了。。。 注意你的mc_config扩展名都没有了。。。
haijie1223 发表于 2012-2-27 22:59 http://www.autoitx.com/images/common/back.gif
你很仔细,狗狗发完贴就跑了,我也没注意少了一个像煤一般的图标 本帖最后由 xms77 于 2012-2-27 23:11 编辑
回复 2# afan
是啊,我怎么就没有看出来呢。现在可以显示图标了,但是图标背景怎么是黑的啊?应该是透明的啊
回复 6# xms77
你确定改了第67行? _GUIImageList_AddIcon 如果图标文件不是DLL或者EXE的话,索引应该为0 ,要不然不能显示了。 回复 7# afan
太粗心了,果然是67行少了个参数3,谢谢afan大大 注意你的mc_config扩展名都没有了。。。
haijie1223 发表于 2012-2-27 22:59 http://www.autoitx.com/images/common/back.gif
忘了提醒你,你后面没有加 0, 1) 参数,图标将是粗糙的小像素图标。 回复 8# lanfengc
谢谢,原来是这样,帮助文件没有看明白,真是头疼啊! 记下了,谢谢各位!
记下了,谢谢各位!
fuldho 发表于 2012-2-28 09:13 http://www.autoitx.com/images/common/back.gif
你这效果就是我在10#提到的,“粗糙的小像素图标”。。。 回复 13# afan
我还以为不是图标组不需要指定呢?
原来也要呀!
谢谢版主提醒。
页:
[1]