本帖最后由 tryhi 于 2015-6-9 18:19 编辑
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("列表视图控件", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
Local $Listview = GUICtrlCreateListView("点击这里 |列 2|列 3 ", 10, 10, 200, 150)
$Listview_handle = GUICtrlGetHandle($Listview)
Local $idItem1 = GUICtrlCreateListViewItem("item1|item1|item1", $Listview)
Local $idItem1 = GUICtrlCreateListViewItem("item2|item2|item2", $Listview)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $hWndFrom, $iCode, $tNMHDR
$tNMHDR = DllStructCreate($tagNMHDR,$LParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $Listview_handle
Switch $iCode
Case $LVN_COLUMNCLICK
Local $tInfo = DllStructCreate($tagNMLISTVIEW,$LParam)
Local $iCol = DllStructGetData($tInfo, "SubItem")
create_shuaixuan()
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY
Func create_shuaixuan()
$mouse_pos = MouseGetPos()
$Form_shuaixuan = GUICreate("筛选窗口", 160, 253, $mouse_pos[0], $mouse_pos[1],BitOR($WS_SYSMENU, $WS_POPUP),-1,$Form1)
GUISetBkColor(0xffffff) ; will change background color
$ListView1 = GUICtrlCreateListView("111 ", 0, 0, 160, 220, $LVS_NOCOLUMNHEADER, _
BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
;~ $button_shai_yes = GUICtrlCreateButton("确定", 10, 225, 50, 20)
;~ $button_shai_no = GUICtrlCreateButton("取消", 80, 225, 50, 20)
For $i = 1 To 50
$item1 = GUICtrlCreateListViewItem("item"&$i, $listview1)
GUICtrlSetState ($item1,$GUI_CHECKED)
Next
GUISetState()
EndFunc
试了注册WM_ACTIVATE消息,但似乎行不通。
不知道这样表达得清不清楚,各位大神运行一下代码应该就能明白
续:--------------------------
我想通过窗口的激活状态来进行判断,但是我发现在消息事件中创建之后的子窗口无论如何都是处于非激活状态,不知道如何让创建之后的子窗口处于激活状态 |