【已解决】WM_Notify的某个Case中嵌套While 1程序假死问题
本帖最后由 imutraveler 于 2017-2-12 11:43 编辑在代码中的279行,在switch右键菜单的 编辑按钮 事件中,引用了函数TreeEdit,而TreeEdit函数创建了已个GUI,这个GUI中使用了消息模式While 1 循环
函数被正常按钮引用的时候,就是正常的,,例如程序界面的上的“添加主机”按钮。
但,,在WM_Notify中的Switch中引用,程序会假死。
#NoTrayIcon
#Region ;**** 由 AccAu3Wrapper_GUI 创建指令 ****
#AccAu3Wrapper_OutFile=Console.exe
#AccAu3Wrapper_UseUpx=Y
#AccAu3Wrapper_UseX64=n
#AccAu3Wrapper_Res_Comment=
#AccAu3Wrapper_Res_Description=远程集中管理
#AccAu3Wrapper_Res_Fileversion=1.0
#AccAu3Wrapper_Res_LegalCopyright=
#AccAu3Wrapper_Res_Language=2052
#AccAu3Wrapper_Res_requestedExecutionLevel=None
#EndRegion ;**** 由 AccAu3Wrapper_GUI 创建指令 ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <GuiTreeView.au3>
#include <TreeViewConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#include <String.au3>
#include <WinAPI.au3>
#include <GuiMenu.au3>
;~ #include <Array.au3>
#include <Constants.au3> ; 托盘事件$TRAY_EVENT_PRIMARYDOUBLE
;~ Opt("GUIOnEventMode", 1) ;事件模式
Opt("GUICloseOnESC", 0) ;禁用 Esc 键退出程序
Opt("TrayMenuMode", 3) ;不显示默认托盘菜单项“脚本暂停/退出”
Opt("TrayOnEventMode", 1) ;响应托盘事件
Opt("TrayIconHide", 1) ;隐藏脚本自身托盘图标
Opt("WinDetectHiddenText", 1) ;检测隐藏窗口的文本或窗口的隐藏文本
Opt("WinTitleMatchMode", 4) ;窗口的匹配模式
;定义变量
Global $DbPath, $DbPass, $TableGroup, $TableServer, $TableUsers, $Conn
Local$Title = "远程集中管理 (控制台) " ,$OemInfo
$OemInfo = ""
;设置主程序窗口标题
If $OemInfo <> "" Then $Title &= " -- " & $OemInfo
;======================== ;;; 开始:创建程序主窗口 ;;; ========================
$Form1 = GUICreate($Title, 960, 615)
;创建 工具栏
$MenuItem1 = GUICtrlCreateMenu("参数设置")
$MenuItem101 = GUICtrlCreateMenuItem("Mstsc 默认选项", $MenuItem1)
$MenuItem102 = GUICtrlCreateMenuItem("功能02", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("管理功能")
$MenuItem103 = GUICtrlCreateMenuItem("用户管理", $MenuItem2)
$MenuItem104 = GUICtrlCreateMenuItem("OEM信息", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("关于程序")
;创建 组框:"搜索"
$SearchGroup = GUICtrlCreateGroup("", 10, 2, 215, 44)
$SearchText = GUICtrlCreateInput("", 21, 14, 120, 25) ;创建搜索文本框
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
$SearchBtn = GUICtrlCreateButton("查找", 145, 13, 70, 27) ;创建查找按钮
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
;创建 组框:"连接按钮"
$BtnGroup = GUICtrlCreateGroup("", 230, 2, 720, 44)
$AddHostBtn = GUICtrlCreateButton("添加主机", 240, 13, 100, 27) ;"添加主机"按钮
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
$AddGroupBtn = GUICtrlCreateButton("添加分组", 350, 13, 100, 27) ;"添加分组"按钮
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
$EditHostBtn = GUICtrlCreateButton("修改主机", 460, 13, 100, 27) ;"修改主机"按钮
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
GUICtrlSetState(-1, $GUI_DISABLE)
$DelHostBtn = GUICtrlCreateButton("删除主机", 570, 13, 100, 27) ;"删除主机"按钮
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
GUICtrlSetState(-1, $GUI_DISABLE)
;创建 TreeView
$TreeView = GUICtrlCreateTreeView(10, 50, 215, 508, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
Local $hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 110)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 131)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 165)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 168)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 137)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 146)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 4)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 45)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 39)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 40)
_GUICtrlTreeView_SetNormalImageList($TreeView, $hImage)
$Group = _GUICtrlTreeView_Add($TreeView, 0, "服务器分组列表", 0, 0)
_GUICtrlTreeView_SetBold($TreeView, $Group)
;~ _GUICtrlTreeView_SetTextColor(-1, 0xff0000)
;创建 TreeView 右键菜单
Local Enum $TreeEdit = 1000, $TreeDelete
Local $TreeContext = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_InsertMenuItem($TreeContext, 0, "修改分组", $TreeEdit)
_GUICtrlMenu_InsertMenuItem($TreeContext, 1, "")
_GUICtrlMenu_InsertMenuItem($TreeContext, 2, "删除分组", $TreeDelete)
;创建 ListView
$ListView = GUICtrlCreateListView("", 230, 50, 720, 310)
_GUICtrlListView_AddColumn($ListView, "名称", 130) ;创建列
_GUICtrlListView_AddColumn($ListView, "隶属分组", 140) ;创建列
_GUICtrlListView_AddColumn($ListView, "IP", 120) ;创建列
_GUICtrlListView_AddColumn($ListView, "端口", 60) ;创建列
_GUICtrlListView_AddColumn($ListView, "备注", 246) ;创建列
_GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) ;设置ListView样式
_GUICtrlListView_SetImageList($ListView, $hImage, 1)
;~ GUICtrlSetColor($ListView , 0xff7f24)
;创建 组框:"手动运行"
$SoftGroup = GUICtrlCreateGroup(" 手动运行 ", 230, 365, 355, 194)
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
;创建 组框:"Mstsc 选项"
$MstscGroup = GUICtrlCreateGroup(" Mstsc 连接选项 ", 590, 365, 360, 97)
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
GUICtrlSetColor($MstscGroup, 0xff7f24)
$MstscRes1024 = GUICtrlCreateRadio(" 1024 x 768", 630, 405, 100, 20)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
$MstscResFull = GUICtrlCreateRadio(" 全屏", 630, 425, 100, 20)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
$MstscResConsole = GUICtrlCreateCheckbox(" 控制台", 750, 385, 120, 25)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
$MstscResFull = GUICtrlCreateCheckbox(" 连接磁盘", 750, 420, 120, 25)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
;创建 组框:"Radmin 中转"
$RadminGroup = GUICtrlCreateGroup(" Radmin 中转 ", 590, 462, 360, 97)
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
;创建 状态栏
$StatusBar = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar_PartsWidth =
_GUICtrlStatusBar_SetParts($StatusBar, $StatusBar_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar, "总计分组: 组", 0)
$GroupCountLabel = GUICtrlCreateLabel("0", 70, 574, 28, 16, $SS_RIGHT)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
GUICtrlSetColor(-1, 0x1c86ee)
_GUICtrlStatusBar_SetText($StatusBar, "主机数量: 台", 1)
$HostCountLabel = GUICtrlCreateLabel("0", 210, 574, 28, 16, $SS_RIGHT)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
GUICtrlSetColor(-1, 0x1c86ee)
_GUICtrlStatusBar_SetText($StatusBar, "当前用户:", 2)
$CurrentUserLabel = GUICtrlCreateLabel("wangzhongheng123", 350, 574, 120, 16)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
GUICtrlSetColor(-1, 0x1c86ee)
_GUICtrlStatusBar_SetText($StatusBar, ""& $OemInfo, 3)
_GUICtrlStatusBar_SetText($StatusBar, "By XXX. 版本:V1.0", 4)
_GUICtrlStatusBar_SetMinHeight($StatusBar, 25)
GUISetState(@SW_SHOW)
;======================== ;;; 结束:创建程序主窗口 ;;; ========================
;======================== ;;; 开始:创建托盘菜单、注册托盘事件 ;;; ========================
;创建 托盘菜单
$TrayAbout = TrayCreateItem("关于程序")
TrayCreateItem("") ;菜单分隔条
$TrayView = TrayCreateItem("显示主窗口")
TrayCreateItem("") ;菜单分隔条
$TrayExit = TrayCreateItem("退出")
;注册 鼠标事件
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
;注册 托盘菜单事件
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TrayEvent") ;注册托盘图标双击事件
TrayItemSetOnEvent($TrayAbout, "TrayEvent") ;注册托盘菜单"关于程序"事件
TrayItemSetOnEvent($TrayView, "TrayEvent") ;注册托盘菜单"显示界面"事件
TrayItemSetOnEvent($TrayExit, "TrayEvent") ;注册托盘菜单"退出"事件
TraySetState(1) ;显示托盘图标
TraySetClick(16) ;释放鼠标右键(显示托盘菜单)
TraySetToolTip("远程集中管理") ;设置托盘图标的提示文本
;======================== ;;; 结束:创建托盘菜单、注册托盘事件 ;;; ========================
Call(ConnectDB) ;连接数据库
;读取 分组列表
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $Conn
;~ $RS.Open("Select * From " & $TableGroup & " Order By GroupName")
$RS.Open("Select * From " & $TableGroup)
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
_GUICtrlTreeView_AddChild($TreeView, $Group, $RS.Fields(1).value, 6, 7) ;生成分组列表
$RS.movenext
WEnd
_GUICtrlTreeView_Sort($TreeView) ;排序TreeView项目
GUICtrlSetData($GroupCountLabel, _GUICtrlTreeView_GetCount($TreeView)) ;设置总计分组label
_GUICtrlTreeView_Expand($TreeView, $Group) ;展开列表
_GUICtrlTreeView_SelectItemByIndex($TreeView, $Group, 0) ;启动时默认选择第一个分组
Local $AutoSelected = GUICtrlRead($TreeView, 1)
Global $lText = $AutoSelected
;~ MsgBox(0, "", $test)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$RS.close
$Conn.Close
Exit
Case $MenuItem102
MsgBox(0, "", "这个是功能2")
Case $AutoSelected ;启动时候生成第一分组的Listview
Call("ShowItems")
$AutoSelected = Null
Case $AddHostBtn
Call("treeedit")
EndSwitch
WEnd
;=============== 函数 - 定义 ===============
Func ConnectDB() ;连接数据库
$DbPath = @ScriptDir & "\" & "Data.mdb"
$DbPass = "123"
$TableGroup = "TB_Group"
$TableServer = "TB_Server"
$TableUsers = "TB_Users"
$Conn = ObjCreate("ADODB.Connection")
$Conn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DbPath & "; Jet OLEDB:Database Password=" & $DbPass)
EndFunc ;==>ConnectDB
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
Local $hWndListView = $ListView,$hWndTreeView = $TreeView
If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
If Not IsHWnd($TreeView) Then $hWndTreeView = GUICtrlGetHandle($TreeView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTreeView
Switch $iCode
Case $NM_CLICK ; 鼠标左键单击
Local $mPos = _WinAPI_GetMousePos(True, $hWndTreeView)
Local $mText = _GUICtrlTreeView_HitTestItem($hWndTreeView, DllStructGetData($mPos, "X"), DllStructGetData($mPos, "Y"))
Local $iPos = _GUICtrlTreeView_HitTest($hWndTreeView, DllStructGetData($mPos, "X"), DllStructGetData($mPos, "Y"))
Local $cText = _GUICtrlTreeView_GetText($hWndTreeView, $mText) ;获得当前坐标项目文本
Local $gText = _GUICtrlTreeView_GetText($hWndTreeView, $Group) ;获得分组标题文本
If $cText <> $gText Then ;判断是否点击了分组标题,若是,则不响应
If ($iPos = 2) Or ($iPos = 4) Or ($iPos = 64) Then ;判断鼠标是否在图标或文本上,若否,则不响应
If $lText <> $cText Then ;判断是否点重复点击,若是,则不响应
$lText = $cText
_GUICtrlTreeView_SelectItem($hWndTreeView, $mText)
Call("ShowItems")
EndIf
EndIf
EndIf
Case $NM_DBLCLK ; 鼠标左键双击
;~ MsgBox(0, "", "双击了<左键>")
Case $NM_RCLICK ; 鼠标右键单击
Local $mPos = _WinAPI_GetMousePos(True, $hWndTreeView)
Local $mText = _GUICtrlTreeView_HitTestItem($hWndTreeView, DllStructGetData($mPos, "X"), DllStructGetData($mPos, "Y"))
Local $iPos = _GUICtrlTreeView_HitTest($hWndTreeView, DllStructGetData($mPos, "X"), DllStructGetData($mPos, "Y"))
Local $cText = _GUICtrlTreeView_GetText($hWndTreeView, $mText) ;获得当前坐标项目文本
Local $gText = _GUICtrlTreeView_GetText($hWndTreeView, $Group) ;获得分组标题文本
If $cText <> $gText Then ;判断是否点击了分组标题,若是,则不响应
If ($iPos = 2) Or ($iPos = 4) Or ($iPos = 64) Then ;判断鼠标是否在图标或文本上,若否,则不响应
If $lText <> $cText Then ;判断是否点重复点击,若是,则不响应
$lText = $cText
_GUICtrlTreeView_SelectItem($hWndTreeView, $mText)
Call("ShowItems")
EndIf
Switch _GUICtrlMenu_TrackPopupMenu($TreeContext, $hWndFrom, -1, -1, 1, 1, 2)
Case $TreeEdit
Call("TreeEdit")
Case $TreeDelete
;~ Call("TreeDelete")
EndSwitch
EndIf
EndIf
EndSwitch
Case $hWndListView
Switch $iCode
Case $NM_CLICK ; 鼠标左键单击
$index = _GUICtrlListView_GetSelectedIndices($ListView)
If $index <> "" Then
;~ MsgBox(0, "", "单击了<左键>")
GUICtrlSetState($EditHostBtn, $GUI_ENABLE)
GUICtrlSetState($DelHostBtn, $GUI_ENABLE)
Else
GUICtrlSetState($EditHostBtn, $GUI_DISABLE)
GUICtrlSetState($DelHostBtn, $GUI_DISABLE)
EndIf
Case $NM_DBLCLK ; 鼠标左键双击
MsgBox(0, "", "双击了<左键>")
Case $NM_RCLICK ; 鼠标右键单击
MsgBox(0, "", _GUICtrlListView_GetSelectedIndices($ListView))
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func ShowItems() ;生成主机列表
_GUICtrlListView_DeleteAllItems($ListView)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $Conn
$RS.open("SELECT * FROM " & $TableServer & " WHERE Groups='" & GUICtrlRead($TreeView, 1) & "'")
Local $i = 0
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
_GUICtrlListView_AddItem($ListView, $RS.Fields(1).value, 4)
_GUICtrlListView_AddSubItem($ListView, $i, $RS.Fields(7).value, 1)
_GUICtrlListView_AddSubItem($ListView, $i, $RS.Fields(2).value, 2)
_GUICtrlListView_AddSubItem($ListView, $i, $RS.Fields(3).value, 3)
_GUICtrlListView_AddSubItem($ListView, $i, $RS.Fields(9).value, 4)
$i += 1
$RS.movenext
WEnd
GUICtrlSetData($HostCountLabel, _GUICtrlListView_GetItemCount($ListView)) ;设置总计主机label
EndFunc ;==>ShowItems
Func TreeEdit() ;修改分组GUI
$TreeEditGUI = GUICreate("修改分组", 300, 100)
$nLabel = GUICtrlCreateLabel("分组名称:" , 50, 23, 60, 25)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
$nInput = GUICtrlCreateInput(GUICtrlRead($TreeView, 1), 110, 20, 140, 25)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
$Btn1 = GUICtrlCreateButton("确定", 90, 65, 70, 27)
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
$Btn2 = GUICtrlCreateButton("取消", 180, 65, 70, 27)
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Btn2
GuiDelete($TreeEditGUI)
WinActivate($Form1, "")
ExitLoop
Case $Btn1
EndSwitch
WEnd
EndFunc ;==>TreeEdit
Func TrayEvent() ;托盘事件
Switch @TRAY_ID
Case $TrayAbout
Call("About")
Case $TrayView, $TRAY_EVENT_PRIMARYDOUBLE
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_RESTORE, $Form1)
Case $TrayExit
Exit
EndSwitch
EndFunc
Func About()
GUISetState(@SW_RESTORE, $Form1)
GUISetState(@SW_DISABLE ,$Form1)
Msgbox(64, "关于程序","远程集中管理(控制台) V1.0 ", 0)
GUISetState(@SW_ENABLE ,$Form1)
GUISetState(@SW_RESTORE, $Form1)
EndFunc 求帮助,求帮助,求帮助啊~~~ 回复 2# imutraveler
以有TreeView右键菜单,为何又要:$AddHostBtn = GUICtrlCreateButton("添加主机"
TreeView右键菜单需加:GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") 本帖最后由 chzj589 于 2016-9-28 09:02 编辑
回复 2# imutraveler
这样是不是你需要的?
本帖最后由 imutraveler 于 2016-9-28 09:47 编辑
回复 4# chzj589
嗯,差不多,
不过你这个,关闭编辑窗口的时候,程序也会退出
$AddHostBtn是为了以后在分组中添加主机使用的,,,现在只是在测试“编辑分组”这个GUI,因为在这个按钮上,程序就不假死,按右键菜单里,程序就假死了
麻烦把修改的部分给我下,我试一试,扩展下思路,哈哈! 回复 5# imutraveler
关闭编辑窗口的时候,程序也会退出?
是关闭TreeView右鍵弹出的修改或删除窗口后,程序会退出?
不会啊!
添加
; 处理 WM_COMMAND 消息
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $lParam
Switch $wParam
Case $TreeEdit
_WinAPI_ShowMsg("你点击了 [修改分组] 菜单")
Case $TreeDelete
_WinAPI_ShowMsg("你点击了 [删除分组]菜单")
EndSwitch
EndFunc ;==>WM_COMMAND 回复chzj589
嗯,差不多,
不过你这个,关闭编辑窗口的时候,程序也会退出
$Add ...
imutraveler 发表于 2016-9-28 09:44 http://www.autoitx.com/images/common/back.gif
关闭编辑窗口的时候,程序也会退出是子窗口关闭$GUI_EVENT_CLOSE的问题,
用:
Func TreeEdit() ;修改分组GUI
$TreeEditGUI = GUICreate("修改分组", 300, 100, -1, -1, $WS_POPUP)
GUICtrlCreateLabel("修改分组", 10, 3, 60, 25)
$nLabel = GUICtrlCreateLabel("分组名称:", 50, 23, 60, 25)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
$nInput = GUICtrlCreateInput(GUICtrlRead($TreeView, 1), 110, 20, 140, 25)
GUICtrlSetFont(-1, 9, 400, 0, "微软雅黑")
$Btn1 = GUICtrlCreateButton("确定", 90, 65, 70, 27)
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
$Btn2 = GUICtrlCreateButton("取消", 180, 65, 70, 27)
GUICtrlSetFont(-1, 10, 400, 0, "微软雅黑")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Btn2
GUIDelete($TreeEditGUI)
WinActivate($Form1, "")
ExitLoop
Case $Btn1
EndSwitch
WEnd
EndFunc ;==>TreeEdit
这样应该可以解决 回复 5# imutraveler
如果子窗口要保留窗口标题,
那就用
Opt("GUIOnEventMode", 1) ;事件模式 本帖最后由 imutraveler 于 2016-9-28 11:07 编辑
回复 6# chzj589
目前右键菜单在WM_Notify中运行挺正常的,在Case $TreeEdit 里用Msgbox都能正常执行,就是条用TreeEdit()函数假死。
现在程序问问题是,在右键菜单的Switch里调用TreeEdit()
1. 为什么会假死呢? 把TreeEdit()里while 1注释掉,就不假死了
2. 为什么$GUI_EVENT_CLOSE和主程序的冲突?
这2个问题,在主界面的其他按钮调用TreeEdit(),就没问题!例如现在$AddHostBtn里测试的,完全正常
还有,不知能否加下你QQ,每次都是你帮忙,论坛有点麻烦,如果可以的话,顺便留下你QQ呗~~ 回复 9# imutraveler
我很少用QQ,论坛里可发短信
我不去问为什么?
只想代码如何通过 回复 9# imutraveler
修改了关闭子窗口假死的问题
回复 9# imutraveler
修改的代码己发论坛里的短信 本帖最后由 imutraveler 于 2016-9-28 14:21 编辑
回复 12# chzj589
嗯,有时候想知道执行失败的原因,知道了原因才能有效的解决问题。
貌似当前的这个问题,窗口不带标题栏就没事儿了??我测试了下,不能带$WS_CAPTION样式。这个真的不太懂,为什么子窗口有标题栏主程序就会假死。。
因为强迫症,子窗口没有标题栏无法接受。。所以纠结了很久!
终于在刚才,我发现,,从开始做右键菜单,到之后的按钮功能,,,消息循环模式给我添了太多麻烦了,各种各样的问题,都是因为消息循环模式,,
感觉到,貌似 “事件驱动模式” 更适合我的程序
所以,尝试了下将 整个程序改为 “事件驱动模式” ,,好像达到了我想要的目的!
修改完的代码已经发送短消息,,还要麻烦你,帮忙看看, 新改的 “事件驱动模式”的代码中,有没有不合适的地方,请指点! 回复 13# imutraveler
不错,我也是喜欢用事件模式 回复 14# chzj589
我写的事件模式的代码,,有没有不合适的地方啊??
页:
[1]
2