#include-once
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>
#include <ImageListConstants.au3>
#include <ToolbarConstants.au3>
#include <WindowsConstants.au3>
Opt('GUIOnEventMode', 1)
Global $width = 800, $hight = 600, $pichight = 562, $labelhight = 560, $labelhight2 = 80
$MainForm = GUICreate('Low Cost Gramload Tester Program (Ver2.5A)', $width, $hight, -1, -1, 0x00070000)
GUISetIcon("C:\Lc_gram\1.ico", -1)
GUISetOnEvent(-3, '_Action')
;==构建菜单项==============================================================
$Menu_File = GUICtrlCreateMenu("&File")
;GUISetOnEvent(-1, '_Action')
$Menu_File_New = GUICtrlCreateMenuItem("New", $Menu_File)
$Menu_File_Open = GUICtrlCreateMenuItem("Open"&@TAB&"F3", $Menu_File)
GUISetOnEvent($Menu_File_Open, '_Action')
$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)
;==创建工具栏边框 ==============================================
GUICtrlCreatePic("", 0,0, $width, $hight - $pichight, 0x08000000, 0x0007)
GUICtrlSetResizing(-1, 512 + 32)
;==创建工具栏按钮===============================================
$ico_open = GUICtrlCreateIcon("D:\images\Open.ICO", -1, 5, 2, 32, 32, -1, 0x0007)
GUICtrlSetResizing(-1, 770 + 32)
GUICtrlSetOnEvent(-1, '_Action')
$ico_save = GUICtrlCreateIcon("D:\images\save.ico", -2, 40, 2, 32, 32, -1, 0x0007)
GUICtrlSetResizing(-1, 770 + 32)
GUICtrlSetOnEvent(-1, '_Action')
$ico_mdconfig = GUICtrlCreateIcon("D:\images\md_config.ico", -2, 75, 2, 32, 32, -1, 0x0007)
GUICtrlSetResizing(-1, 770 + 32)
GUICtrlSetOnEvent(-1, '_Action')
$ico_hdconfig = GUICtrlCreateIcon("D:\images\HD_factor.ico", -2, 110, 2, 32, 32, -1, 0x0007)
GUICtrlSetResizing(-1, 770 + 32)
GUICtrlSetOnEvent(-1, '_Action')
$ico_mcconfig = GUICtrlCreateIcon("D:\images\mc_config.ico", -2, 145, 2, 32, 32, -1, 0x0007)
GUICtrlSetResizing(-1, 770 + 32)
GUICtrlSetOnEvent(-1, '_Action')
$ico_exit = GUICtrlCreateIcon("D:\images\Close.ico", -2, 180, 2, 32, 32, -1, 0x0007)
GUICtrlSetResizing(-1, 770 + 32)
GUICtrlSetOnEvent(-1, '_Action')
$Graphic = GUICtrlCreateGraphic(0, $hight - $labelhight, $width, $hight - $labelhight2, -1)
GUICtrlSetBkColor(-1, 0x848285)
GUICtrlSetResizing(-1, 32)
$hStatus = _GUICtrlStatusBar_Create($MainForm, -1, '', $SBARS_SIZEGRIP, 0x0007)
_GUICtrlStatusBar_SetParts($hStatus, -1)
GUISetState()
;注册Windows消息函数
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
While 1
$msg = GUIGetMsg()
Select
Case $msg = -3
Exit
;Case $Menu_File_Open
; _openfile()
;Case $msg = $ico2
;ButtonAnime($GUI, $ico2)
; Case $msg = $ico3
;ButtonAnime($GUI, $ico3)
; Case $msg = $ico4
; ButtonAnime($GUI, $ico4)
EndSelect
WEnd
Func _Action()
Switch @GUI_CtrlId
Case -3
Exit
Case $ico_open
buttonanime($MainForm,$ico_open)
_openfile()
Case $ico_save
buttonanime($MainForm,$ico_save)
Case $ico_mdconfig
buttonanime($MainForm,$ico_mdconfig)
Case $ico_hdconfig
buttonanime($MainForm,$ico_hdconfig)
Case $ico_mcconfig
buttonanime($MainForm,$ico_mcconfig)
Case $ico_exit
buttonanime($MainForm,$ico_exit)
Exit
Case $Menu_File_Open
_openfile()
EndSwitch
EndFunc
Func ButtonAnime($_Hwd, $_Botton)
Local $_pos = ControlGetPos($_Hwd, "", $_Botton)
GUICtrlSetPos($_Botton, $_pos[0] + 1, $_pos[1] + 1)
Sleep(100)
GUICtrlSetPos($_Botton, $_pos[0], $_pos[1])
EndFunc ;==>ButtonAnime
;根据窗口大小,调整状态栏
Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam, $ilParam
_GUICtrlStatusBar_Resize($hStatus)
GUICtrlSetPos($Graphic, 0, $hight - $labelhight, @DesktopWidth * 3, @DesktopHeight * 3)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
Func WM_GETMINMAXINFO($hWnd, $msg, $wparam, $lparam)
Local $tagMINMAXINFO = "int;int;int;int;int;int;int;int;int;int"
$MINMAXINFO = DllStructCreate($tagMINMAXINFO, $lparam)
DllStructSetData($MINMAXINFO, 7, 300) ;minx
DllStructSetData($MINMAXINFO, 8, 200) ;miny
DllStructSetData($MINMAXINFO, 9, @DesktopWidth) ;maxx
DllStructSetData($MINMAXINFO, 10, @DesktopHeight - 30) ;maxy
EndFunc ;==>WM_GETMINMAXINFO
Func _openfile()
Local $var = FileOpenDialog("Open", "C:\Lc_gram", "cfg Files (*.cfg)|All Files (*.*)",1,"",$MainForm )
EndFunc ;==> _openfile