#NoTrayIcon
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3>
#include <TreeViewConstants.au3>
#include <ButtonConstants.au3>
#Include <WinAPIEx.au3>
#Include <Constants.au3 >
#Include <WinAPI.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
Opt("TrayMenuMode", 3);没有默认菜单
Dim $databaseIp = '192.168.1.221', $databaseName = 'sa', $databasePwd ='abc123'
Global $mainGUI,$tpyj1,$tpyj2,$tptc,$fatongzhi,$yijian,$fasong,$renyuanmingdan,$quanxuan,$idTreeview
Global $fatongzhitab,$quanbuxuan,$Conn,$RS,$shijian = @YEAR&"-"&@MON&"-"&@MDAY&"-"&@HOUR&":"&@MIN&":"&@SEC
_maingui()
Func _maingui() ;主窗口
$mainGUI = GUICreate("行政软件",800,600,192,124,BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_MAXIMIZE,$WS_TABSTOP))
GUICtrlCreateTab(0, 0, @DesktopWidth, @DesktopHeight)
_fatongzhi()
_yijian()
TrayItemSetState(-1,$TRAY_FOCUS)
$tpyj1 = TrayCreateItem("右键1",-1,-1,-1)
$tpyj2 = TrayCreateItem("右键2",-1,-1,-1)
$tptc = TrayCreateItem("退出",-1,-1,-1)
GUISetState(@SW_SHOW,$mainGUI)
_GUICloseEvent()
EndFunc
Func _fatongzhi() ;发通知
$fatongzhitab = GUICtrlCreateTabItem("发通知")
GUICtrlCreateLabel("请在下面输入要发送的内容",30,40,BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_MAXIMIZE,$WS_TABSTOP))
GUICtrlCreateLabel("请在下面选择要发送的人员名单",710,40,BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_MAXIMIZE,$WS_TABSTOP))
$fatongzhi = GUICtrlCreateEdit("",30,60,600,400,$ws_vscroll + $es_wantreturn)
$fasong = GUICtrlCreateButton("发送",290,470,80,40)
$quanxuan = GUICtrlCreateButton("全选",800,470,80,40)
$quanbuxuan = GUICtrlCreateButton("重选",1000,470,80,40)
$idTreeview = GUICtrlCreateTreeView(700,60,600,400,BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES))
Global $renyuan[10][20]
$jishubu = GUICtrlCreateTreeViewItem("技术部",$idTreeview)
$renyuan[0][0] = GUICtrlCreateTreeViewItem("a",$jishubu)
$renyuan[0][1] = GUICtrlCreateTreeViewItem("aa",$jishubu)
$renyuan[0][2] = GUICtrlCreateTreeViewItem("aaa",$jishubu)
$renyuan[0][3] = GUICtrlCreateTreeViewItem("aaaa",$jishubu)
$renyuan[0][4] = GUICtrlCreateTreeViewItem("aaaaa",$jishubu)
$renyuan[0][5] = GUICtrlCreateTreeViewItem("aaaaaa",$jishubu)
$renyuan[0][6] = GUICtrlCreateTreeViewItem("aaaaaaa",$jishubu)
$renyuan[0][7] = GUICtrlCreateTreeViewItem("aaaaaaaa",$jishubu)
$qihua = GUICtrlCreateTreeViewItem("企划部",$idTreeview)
$renyuan[1][0] = GUICtrlCreateTreeViewItem("1",$qihua)
$renyuan[1][1] = GUICtrlCreateTreeViewItem("2",$qihua)
$renyuan[1][2] = GUICtrlCreateTreeViewItem("3",$qihua)
$renyuan[1][3] = GUICtrlCreateTreeViewItem("4",$qihua)
$renyuan[1][4] = GUICtrlCreateTreeViewItem("5",$qihua)
$xiangmu = GUICtrlCreateTreeViewItem("项目1",$idTreeview)
$renyuan[2][0] = GUICtrlCreateTreeViewItem("6",$xiangmu)
$renyuan[2][1] = GUICtrlCreateTreeViewItem("7",$xiangmu)
$renyuan[2][2] = GUICtrlCreateTreeViewItem("8",$xiangmu)
$xiangmu2 = GUICtrlCreateTreeViewItem("项目2",$idTreeview)
$renyuan[3][0] = GUICtrlCreateTreeViewItem("9",$xiangmu2)
$renyuan[3][1] = GUICtrlCreateTreeViewItem("10",$xiangmu2)
$renyuan[3][2] = GUICtrlCreateTreeViewItem("11",$xiangmu2)
$zixun = GUICtrlCreateTreeViewItem("咨询部",$idTreeview)
$renyuan[4][0] = GUICtrlCreateTreeViewItem("12",$zixun)
$renyuan[4][1] = GUICtrlCreateTreeViewItem("13",$zixun)
$renyuan[4][2] = GUICtrlCreateTreeViewItem("14",$zixun)
$xinzhen = GUICtrlCreateTreeViewItem("行政",$idTreeview)
$renyuan[5][0] = GUICtrlCreateTreeViewItem("15",$xinzhen)
$renyuan[5][1] = GUICtrlCreateTreeViewItem("16",$xinzhen)
$renyuan[5][2] = GUICtrlCreateTreeViewItem("17",$xinzhen)
EndFunc
Func _quanxuan($status) ;全选和全不选
$childWndArray = _WinAPI_EnumChildWindows($mainGUI)
If IsArray($childWndArray) Then
If $status Then
For $i=1 To $childWndArray[0][0]
If $childWndArray[$i][1] = "Button" Then
$btnStyle = _WinAPI_GetWindowLong($childWndArray[$i][0], $GWL_STYLE)
If BitAND($btnStyle, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX Then
_SendMessage($childWndArray[$i][0], $BM_SETCHECK, $BST_CHECKED)
EndIf
EndIf
Next
Else
For $i=1 To $childWndArray[0][0]
If $childWndArray[$i][1] = "Button" Then
$btnStyle = _WinAPI_GetWindowLong($childWndArray[$i][0], $GWL_STYLE)
If BitAND($btnStyle, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX Then
_SendMessage($childWndArray[$i][0], $BM_SETCHECK, $BST_UNCHECKED)
EndIf
EndIf
Next
EndIf
EndIf
EndFunc
;~ Func _fasong() ;发送
;~ $sql = "insert into tongzhi values "
;~
;~ For $i = $xuanxiang[0] To $xuanxiang[7]
;~ If BitAND(GUICtrlRead($i), $GUI_CHECKED) Then
;~ $sql =$sql & "('" & GUICtrlRead($i,1) & "','" & GUICtrlRead($fatongzhi) & "','" & $shijian & "'),"
;~ EndIf
;~ Next
;~ $sql=StringLeft($sql,StringLen($sql)-1)
;~ _databaseOpen()
;~ $Conn.Execute($sql)
;~
;~ $RS = ObjCreate("ADODB.Recordset")
;~ $RS.ActiveConnection = $Conn
;~ $rs.open("select id from tongzhi where convert(nvarchar(255),neirong) ='" & GUICtrlRead($fatongzhi) & "'")
;~ While (Not $RS.eof And Not $RS.bof)
;~ $id = $rs.fields("id").value
;~ $RS.movenext
;~ WEnd
;~ If $id > 0 Then
;~ $rs.close
;~ $Conn.close
;~ MsgBox(0,"ok","已经发送")
;~ EndIf
;~
;~ EndFunc
Func _yijian() ;意见
GUICtrlCreateTabItem("意见建议")
EndFunc
Func _tpyj1() ;右键托盘1
MsgBox(64,"提示","你点击了右键1")
EndFunc
Func _tpyj2() ;右键托盘2
MsgBox(64,"提示","你点击了右键2")
EndFunc
Func _zuixiaohua() ;最小化
TraySetState(1)
GUISetState(@SW_HIDE, $mainGUI)
EndFunc
Func _huifu() ;恢复
GUISetState(@SW_SHOW, $mainGUI)
TraySetState(2)
EndFunc
Func _exit() ;退出
Exit
GUIDelete($mainGUI)
EndFunc
Func _GUICloseEvent() ;所有事件
Local $aMsg = 0
While 1
$aMsg = GUIGetMsg(1)
Switch $aMsg[1]
Case $mainGUI
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE
ExitLoop
Case $GUI_EVENT_MINIMIZE
_zuixiaohua()
Case $quanxuan
_quanxuan(True)
;~ ConsoleWrite(_quanxuan(True))
;~ Case $fasong
;~ _fasong()
Case $quanbuxuan
_quanxuan(False)
EndSwitch
EndSwitch
Switch TrayGetMsg() ;获取托盘事件
Case $TRAY_EVENT_PRIMARYDOUBLE
_huifu()
Case $tpyj1
_tpyj1()
Case $tpyj2
_tpyj2()
Case $tptc
_exit()
EndSwitch
WEnd
GUIDelete($mainGUI)
EndFunc
Func _databaseOpen() ;打开数据库
$Conn=ObjCreate("ADODB.Connection")
$Conn.open("DRIVER={SQL Server};SERVER="& $databaseIp & ";UID="& $databaseName & ";PWD="& $databasePwd & ";")
$Conn.Execute("use xinzhengguanli")
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $Conn
EndFunc
Func _databaseclose() ;关闭数据库
$Conn.close
EndFunc
希望按全选的时候,全部选上,重选的时候,全部不选。按部门按钮,部门一下全部选择。感谢,感谢,求思路,求解决。万分感谢