找回密码
 加入
搜索
查看: 4853|回复: 3

[GUI管理] (已解决)while 没法退出 gui不能关闭 GUIGetMsg高级模式出错

[复制链接]
发表于 2015-5-7 09:26:06 | 显示全部楼层 |阅读模式
本帖最后由 ak47gglllk 于 2015-5-7 17:19 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Global $TabSheet[6], $ListView[6], $Button[11], $youjian[6], $shuaxin[6]
Global $Form1
_maingui()

Func _maingui()
        Local $Form1 = GUICreate("Form1", 683, 516, 365, 125)
        Local $Tab1 = GUICtrlCreateTab(16, 64, 649, 393)
        Local $Label1 = GUICtrlCreateLabel("Label1", 200, 16, 244, 33)
        _duanxin()
        _wenhou()
        _jingdian()
        _anlie()
        _dengdeng()
        GUICtrlCreateTabItem("")
        GUISetState(@SW_SHOW)
        _GUICloseEvent()
EndFunc   ;==>_maingui

Func _duanxin()
        $TabSheet[1] = GUICtrlCreateTabItem("短信")
        $ListView[1] = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
        GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
        $Button[1] = GUICtrlCreateButton("添加", 144, 408, 75, 25)
        $Button[2] = GUICtrlCreateButton("生成", 432, 408, 75, 25)
        Local $aFileList = _FileListToArray("D:\短信", "*")
        Local $iRows = UBound($aFileList)
        For $i = 1 To $iRows - 1 Step 1
                Local $idItem = GUICtrlCreateListViewItem($i & "|" & $aFileList[$i], $ListView[1])
        Next
EndFunc   ;==>_duanxin

Func _wenhou()
        $TabSheet[2] = GUICtrlCreateTabItem("问候")
        $ListView[2] = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
        GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
        $Button[3] = GUICtrlCreateButton("添加", 96, 408, 75, 25)
        $Button[4] = GUICtrlCreateButton("生成", 472, 408, 75, 25)
        Local $aFileList = _FileListToArray("D:\问候", "*")
        Local $iRows = UBound($aFileList)
        For $i = 1 To $iRows - 1 Step 1
                Local $idItem = GUICtrlCreateListViewItem($i & "|" & $aFileList[$i], $ListView[2])
        Next
EndFunc   ;==>_wenhou

Func _jingdian()
        $TabSheet[3] = GUICtrlCreateTabItem("经典")
        $ListView[3] = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
        GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
        $Button[5] = GUICtrlCreateButton("添加", 112, 416, 75, 25)
        $Button[6] = GUICtrlCreateButton("生成", 416, 416, 75, 25)
        Local $aFileList = _FileListToArray("D:\经典", "*")
        Local $iRows = UBound($aFileList)
        For $i = 1 To $iRows - 1 Step 1
                Local $idItem = GUICtrlCreateListViewItem($i & "|" & $aFileList[$i], $ListView[3])
        Next
EndFunc   ;==>_jingdian

Func _anlie()
        $TabSheet[4] = GUICtrlCreateTabItem("案例")
        $ListView[4] = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
        GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
        $Button[7] = GUICtrlCreateButton("添加", 128, 408, 75, 25)
        $Button[8] = GUICtrlCreateButton("生成", 384, 416, 75, 25)
        Local $aFileList = _FileListToArray("D:\案例", "*")
        Local $iRows = UBound($aFileList)
        For $i = 1 To $iRows - 1 Step 1
                Local $idItem = GUICtrlCreateListViewItem($i & "|" & $aFileList[$i], $ListView[4])
        Next
EndFunc   ;==>_anlie

Func _dengdeng()
        $TabSheet[5] = GUICtrlCreateTabItem("等等")
        $ListView[5] = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
        GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
        $Button[9] = GUICtrlCreateButton("添加", 176, 416, 75, 25)
        $Button[10] = GUICtrlCreateButton("生成", 432, 416, 75, 25)
        Local $aFileList = _FileListToArray("D:\等等", "*")
        Local $iRows = UBound($aFileList)
        For $i = 1 To $iRows - 1 Step 1
                Local $idItem = GUICtrlCreateListViewItem($i & "|" & $aFileList[$i], $ListView[5])
        Next
EndFunc   ;==>_dengdeng

Func WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) ;鼠标左键右键双击
        
        Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
        Local $tagNMHDR = DllStructCreate("int;int;int", $lParam)
        If @error Then Return $GUI_RUNDEFMSG
        $IDFrom = DllStructGetData($tagNMHDR, 2)
        $Event = DllStructGetData($tagNMHDR, 3)
        $tagNMHDR = 0
        Switch $IDFrom;选择产生事件的控件
                Case $ListView[1]
                        Switch $Event; 选择产生的事件
                                
                                Case $NM_CLICK ; 左击
                                        
                                Case $NM_DBLCLK ;双击
;~                                                                MsgBox(0,0,"你双击了")
                                Case $NM_RCLICK ; 右击
                                        GUICtrlDelete($youjian[1])
                                        $youjian[1] = GUICtrlCreateContextMenu($ListView[1])
                                        $shuaxin[1] = GUICtrlCreateMenuItem("刷新", $youjian[1])

                        EndSwitch
                Case $ListView[2]
                        Switch $Event
                                Case $NM_RCLICK
                                        GUICtrlDelete($youjian[2])
                                        $youjian[2] = GUICtrlCreateContextMenu($ListView[2])
                                        $shuaxin[2] = GUICtrlCreateMenuItem("刷新", $youjian[2])
                        EndSwitch
;~
        EndSwitch
EndFunc   ;==>WM_NOTIFY

Func _GUICloseEvent()
        Local $aMsg = 0
        While 1
                $nMsg = GUIGetMsg(1)
                Switch $nMsg[1]
                        Case $Form1
                                Switch $nMsg[0]
                                        Case $GUI_EVENT_CLOSE
                                                Exit
                                        Case $Button[1]
                                                MsgBox(0, 0, "1")
                                        Case $Button[2]
                                                MsgBox(0, 0, "2")
                                        Case $Button[3]
                                                MsgBox(0, 0, "3")
                                        Case $Button[4]
                                                MsgBox(0, 0, "4")
                                        Case $Button[5]
                                                MsgBox(0, 0, "5")
                                        Case $Button[6]
                                                MsgBox(0, 0, "6")
                                        Case $Button[7]
                                                MsgBox(0, 0, "7")
                                        Case $Button[8]
                                                MsgBox(0, 0, "8")
                                        Case $Button[9]
                                                MsgBox(0, 0, "9")
                                        Case $Button[10]
                                                MsgBox(0, 0, "10")
                                EndSwitch

                EndSwitch
        WEnd
EndFunc   ;==>_GUICloseEvent
求帮助,求解答,求思路。谢谢。非常感谢
发表于 2015-5-7 16:39:09 | 显示全部楼层
$form1在_mainGUI函数中又重新定义为local
造成全局$form1没有赋值。所以在 _GUICloseEven中的$form1是没有初始化的。
 楼主| 发表于 2015-5-7 17:17:34 | 显示全部楼层
回复 2# h20040606


    大神,请收下我的膝盖。感谢,感谢。完美解决
发表于 2015-5-7 18:49:21 | 显示全部楼层
回复 3# ak47gglllk

不客气。共同进步
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 11:57 , Processed in 0.081607 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表