|
发表于 2008-9-6 17:06:19
|
显示全部楼层
#AutoIt3Wrapper_UseAnsi=y
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#Region
$Form_main = GUICreate("$Form_main", 703, 446)
$Button_show_subgui = GUICtrlCreateButton("显示", 598, 19, 75, 25, 0)
; ListView
Global $ListView_main = _GUICtrlListView_Create($Form_main, "", 10, 65, 681, 330, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
; Add columns
_GUICtrlListView_InsertColumn($ListView_main, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($ListView_main, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($ListView_main, 2, "Column 3", 100)
; Add items
_GUICtrlListView_AddItem($ListView_main, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($ListView_main, 0, "Row 1: Col 2", 1)
_GUICtrlListView_AddSubItem($ListView_main, 0, "Row 1: Col 3", 2)
_GUICtrlListView_AddItem($ListView_main, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($ListView_main, 1, "Row 2: Col 2", 1)
_GUICtrlListView_AddItem($ListView_main, "Row 3: Col 1", 2)
Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListView_main)]
_GUICtrlListView_SetExtendedListViewStyle($ListView_main, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $GUI_DOCKAUTO))
GUICtrlSendMsg($ListView_main, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
#EndRegion
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $Button_show_subgui
_subgui_show()
EndSelect
WEnd
Func _subgui_show()
GUISetState(@SW_HIDE,$Form_main)
$Form_show = GUICreate("$Form_show", 400, 300)
$Button_close_subgui = GUICtrlCreateButton("关闭子窗口",10,10)
GUISetState(@SW_SHOW)
While 1
sleep (10)
Switch guigetmsg()
Case $Button_close_subgui
GUISetState(@SW_SHOW ,$Form_main)
GUIDelete($Form_show)
ExitLoop
EndSwitch
WEnd
EndFunc ;==>_gui_show
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
Local $HDR_hwndFrom, $HDR_code, $HDR_tNM
$HDR_tNM = DllStructCreate($tagNMHDR, $lParam)
$HDR_hwndFrom = HWnd(DllStructGetData($HDR_tNM, "hWndFrom"))
$HDR_code = DllStructGetData($HDR_tNM, "Code")
Switch $HDR_hwndFrom
Case $ListView_main
Switch $HDR_code
Case $LVN_COLUMNCLICK ; A column was clicked
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
;ListView排序
_GUICtrlListView_SimpleSort($ListView_main, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
Case $NM_RCLICK ; 右击
If _GUICtrlListView_GetSelectedCount($ListView_main) >= 1 Then
;~ ShowMenu($Form_main, $OptionsContext)
EndIf
Case $NM_DBLCLK ; <strong><font color="#FF0000">双击</font></strong>
If _GUICtrlListView_GetSelectedCount($ListView_main) >= 1 Then
_subgui_show()
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFY |
|