ak47gglllk 发表于 2015-5-7 09:26:06

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

本帖最后由 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, $ListView, $Button, $youjian, $shuaxin
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 = GUICtrlCreateTabItem("短信")
      $ListView = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
      GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
      $Button = GUICtrlCreateButton("添加", 144, 408, 75, 25)
      $Button = 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)
      Next
EndFunc   ;==>_duanxin

Func _wenhou()
      $TabSheet = GUICtrlCreateTabItem("问候")
      $ListView = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
      GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
      $Button = GUICtrlCreateButton("添加", 96, 408, 75, 25)
      $Button = 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)
      Next
EndFunc   ;==>_wenhou

Func _jingdian()
      $TabSheet = GUICtrlCreateTabItem("经典")
      $ListView = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
      GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
      $Button = GUICtrlCreateButton("添加", 112, 416, 75, 25)
      $Button = 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)
      Next
EndFunc   ;==>_jingdian

Func _anlie()
      $TabSheet = GUICtrlCreateTabItem("案例")
      $ListView = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
      GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
      $Button = GUICtrlCreateButton("添加", 128, 408, 75, 25)
      $Button = 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)
      Next
EndFunc   ;==>_anlie

Func _dengdeng()
      $TabSheet = GUICtrlCreateTabItem("等等")
      $ListView = GUICtrlCreateListView("序号|文章", 24, 88, 634, 302, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
      GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
      $Button = GUICtrlCreateButton("添加", 176, 416, 75, 25)
      $Button = 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)
      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
                        Switch $Event; 选择产生的事件
                              
                              Case $NM_CLICK ; 左击
                                       
                              Case $NM_DBLCLK ;双击
;~                                                                MsgBox(0,0,"你双击了")
                              Case $NM_RCLICK ; 右击
                                        GUICtrlDelete($youjian)
                                        $youjian = GUICtrlCreateContextMenu($ListView)
                                        $shuaxin = GUICtrlCreateMenuItem("刷新", $youjian)

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

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

                EndSwitch
      WEnd
EndFunc   ;==>_GUICloseEvent
求帮助,求解答,求思路。谢谢。非常感谢

h20040606 发表于 2015-5-7 16:39:09

$form1在_mainGUI函数中又重新定义为local
造成全局$form1没有赋值。所以在 _GUICloseEven中的$form1是没有初始化的。

ak47gglllk 发表于 2015-5-7 17:17:34

回复 2# h20040606


    大神,请收下我的膝盖。感谢,感谢。完美解决

h20040606 发表于 2015-5-7 18:49:21

回复 3# ak47gglllk

不客气。共同进步
页: [1]
查看完整版本: (已解决)while 没法退出 gui不能关闭 GUIGetMsg高级模式出错