#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
Global $hListItem[2]
Global $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $aHit
Global $iColor, $iColorBk, $fChildGui = False
$Main_GUI = GuiCreate("test", 924, 604, 60, 20)
$hListView = GuiCtrlCreateListView("", 10, 44, 904, 535, -1, BitOR($LVS_ICON, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_TWOCLICKACTIVATE))
$hListView = GUICtrlGetHandle($hListView) ; necessary for _SubItemHitTest
_GUICtrlListView_AddColumn($hListView, " ", 20)
_GUICtrlListView_AddColumn($hListView, "TIME", 40, 1)
_GUICtrlListView_AddColumn($hListView, "PROVIDER ", 70)
_GUICtrlListView_AddColumn($hListView, "CHART # ", 70)
_GUICtrlListView_AddColumn($hListView, "PATIENT NAME ", 155)
_GUICtrlListView_AddColumn($hListView, "NOTE ", 158)
_GUICtrlListView_AddColumn($hListView, "RESOURCE", 72)
_GUICtrlListView_AddColumn($hListView, "STATUS ", 74)
_GUICtrlListView_AddColumn($hListView, "CLAIM(S) ", 80)
_GUICtrlListView_AddColumn($hListView, "LEDGER", 72)
_GUICtrlListView_AddColumn($hListView, "DICTATION", 72)
$Status_Message = GUICtrlCreateLabel("", 20, 582, 180, 20)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
;_GUICtrlListView_BeginUpdate($hListView)
$hListItem[1] = _GUICtrlListView_AddItem($hListView, " ")
_GUICtrlListView_AddSubItem($hListView, 0, "11:30", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "XYZZY", 2)
_GUICtrlListView_AddSubItem($hListView, 0, "PLUGH", 3)
_GUICtrlListView_AddSubItem($hListView, 0, "DOE, JOHN", 4)
_GUICtrlListView_AddSubItem($hListView, 0, "PLOVER", 5)
_GUICtrlListView_AddSubItem($hListView, 0, "FOOBAR", 6)
_GUICtrlListView_AddSubItem($hListView, 0, "CLICK ME", 7)
_GUICtrlListView_AddSubItem($hListView, 0, "12345", 8)
_GUICtrlListView_AddSubItem($hListView, 0, "01-01-2009", 9)
_GUICtrlListView_AddSubItem($hListView, 0, "01-31-2009", 10)
;_GUICtrlListView_EndUpdate($hListView)
;-----------------------------------------------------------------------------------------------------------
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3 ; $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
If $fChildGui Then
Child_GUI($aHit[0])
$fChildGui = False
EndIf
Wend
Exit
;-----------------------------------------------------------------------------------------------------------
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_ENDSCROLL
$tNMHDR = DllStructCreate("hwnd hWnd;uint cID;int code", $ilParam)
$hLV = HWnd(DllStructGetData($tNMHDR, "hWnd"))
_WinAPI_InvalidateRect($hLV)
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$aHit = _GUICtrlListView_SubItemHitTest($hListView)
If $aHit[0] < 0 Then Return $GUI_RUNDEFMSG
Switch $aHit[1]
Case 7
$fChildGui = True
;Child_GUI($aHit[0])
EndSwitch
Case $NM_CUSTOMDRAW
Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam)
Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")
If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW
If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW
Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")
If $iSubItem Then
$iColor = 0x000000
$iColorBk = 0xFFFFFF
Switch $iSubItem
Case 4
$iColor = 0xFFFFFF
$iColorBk = 8421376
Case 6
$iColor = 0x0080FF
Case 7
$iColor = 0x888888
Case 8
$iColor = 0x228B22
Case 9
$iColor = 0xFF0000
Case 10
$iColor = 0x0000FF
EndSwitch
DllStructSetData($tCustDraw, "clrTextBk", $iColorBk)
DllStructSetData($tCustDraw, "clrText", $iColor)
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
;-----------------------------------------------------------------------------------------------------------
Func Child_GUI($y)
; GUISetState(@SW_LOCK, $Main_GUI) ; uncommented changes behaviour
$APPTSTAT_GUI = GUICreate("", 230, 180, 560, 140)
GUISetState(@SW_SHOW, $APPTSTAT_GUI)
While 1
$msg2 = GUIGetMsg()
Switch $msg2
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
Sleep(50) ; why is this necessary? otherwise crashes
Wend
GUIDelete($APPTSTAT_GUI)
GUISetState(@SW_RESTORE, $Main_GUI)
; GUISetState(@SW_UNLOCK, $Main_GUI); uncommented changes behaviour
EndFunc |