#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <array.au3>
#Include <GuiListView.au3>
#Include <GuiTab.au3>
Global $BarName,$Xzhong
#Region ### START Koda GUI section ### Form=
$Gui = GUICreate("Form1", 434, 457, 225, 115)
$Group1 = GUICtrlCreateGroup("", 8, 10, 413, 251)
$ListView1 = GUICtrlCreateListView("名称 | 类型", 19, 28, 390, 218)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 168)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 128)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 8, 270, 413, 95)
$Label1 = GUICtrlCreateLabel("选择网吧:", 26, 300, 80, 25)
$Combo1 = GUICtrlCreateCombo("", 80, 296, 160, 25)
$Label1 = GUICtrlCreateLabel("当前:未选中网吧", 231, 332, 180, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("", 49, 376, 317, 65)
$Button1 = GUICtrlCreateButton("Button1", 74, 398, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 167, 398, 75, 25)
$Button3 = GUICtrlCreateButton("Button3", 260, 398, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListViewButton = GUICtrlCreateContextMenu($ListView1)
$ListBut_1 = GUICtrlCreateMenuItem("连接", $ListViewButton)
$ListBut_2 = GUICtrlCreateMenuItem("游戏转发", $ListViewButton)
$ListBut_3 = GUICtrlCreateMenuItem("主服转发", $ListViewButton)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlCreateListViewItem('主服务器|aaa', $ListView1)
GUICtrlCreateListViewItem('游戏更新|bbb', $ListView1)
GUICtrlCreateListViewItem('副服务器|ccc', $ListView1)
GUICtrlCreateListViewItem('副服务器|ddd', $ListView1)
$Xiala = "请选择网吧...|"&$BarName
GUICtrlSetData($Combo1, $Xiala, "请选择网吧...")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
Sleep (1000)
WEnd
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $iCtrl = BitAND($wParam, 0x0000FFFF)
Local $iCode = BitShift($wParam, 16)
Switch $hWnd
Case $Gui
Switch $iCtrl
Case $Button1
Case $Button2
Case $Button3
Exit
Case $ListBut_1
MsgBox(0,0,"连接")
Case $ListBut_2
MsgBox(0,0,"游戏转发")
Case $ListBut_3
MsgBox(0,0,"主服转发")
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
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 $ListView1
Switch $Event; 选择产生的事件
Case $NM_RCLICK ; 右击
GUICtrlDelete($ListBut_1)
GUICtrlDelete($ListBut_2)
GUICtrlDelete($ListBut_3)
$ss = StringSplit(GUICtrlRead(GUICtrlRead($ListView1)), '|')
If $ss[0] <> 1 Then
If $ss[1] = '副服务器' Then
$ListBut_3 = GUICtrlCreateMenuItem("主服转发", $ListViewButton)
$ListBut_2 = GUICtrlCreateMenuItem("游戏转发", $ListViewButton)
ElseIf $SS[1] = '主服务器' Then
$ListBut_1 = GUICtrlCreateMenuItem("连接", $ListViewButton)
ElseIf $SS[1] = '游戏更新' Then
$ListBut_1 = GUICtrlCreateMenuItem("连接", $ListViewButton)
EndIf
Else
MsgBox(0,"错误","未选中网吧!请重新选择")
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nID = BitAND($wParam, 0x0000FFFF)
Switch $nID
Case 0xf060
If $hWnd = $Gui Then
Exit
Else
GUIDelete($hWnd)
EndIf
EndSwitch
EndFunc ;==>WM_SYSCOMMAND
发现新问题。。。。。 。如果先选择了主服务器然后右键 点击了连接以后 。。。。。