dragonlord Posted June 2, 2013 Share Posted June 2, 2013 I'm hottracking a listview using the below code: expandcollapse popupFunc WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") If Not IsHWnd($hTab) Then $hWndTab = GUICtrlGetHandle($Tab1) Switch $hWndFrom Case $hListView2 Switch $iCode Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tInfo, "Item") $iSubItem = DllStructGetData($tInfo, "SubItem") _GUICtrlStatusBar_SetText($hStatus, $iItem &","&$iSubItem ) Case $NM_CUSTOMDRAW If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;' & _ 'dword DrawStage;hwnd hdc;long rect[4];dword ItemSpec;int ItemState;dword Itemlparam;' & _ 'dword clrText;dword clrTextBk;int SubItem;' & _ 'dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText[4];int Align', _ ;winxp or later $lParam), $iDrawStage, $iItem, $iSubitem, $hDC, $iColor1, $iColor2, $iColor3 $iDrawStage = DllStructGetData($tCustDraw, 'DrawStage') If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ;request drawing each cell separately If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT $iItem = DllStructGetData($tCustDraw, 'ItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'SubItem') ;~ ConsoleWrite(@CRLF & "$iItem = " & $iItem & ", $iSubitem ="&$iSubitem &", text="& _GUICtrlListView_GetItemText($hListView2, $iItem ,$iSubitem)) $iColor1 = RGB2BGR(0xFBFFD8) $iColor2 = RGB2BGR(-1) $iColor3 = RGB2BGR(0xFF0000) $ColorDisabletext=RGB2BGR(0xdcdcdc) if StringInStr(_GUICtrlListView_GetItemText($hListView2, $iItem ,$iSubitem),"Fail") Then DllStructSetData($tCustDraw, 'clrTextBk', $iColor2) DllStructSetData($tCustDraw, 'clrText', RGB2BGR(0xcd5c5c)) EndIf if StringInStr(_GUICtrlListView_GetItemText($hListView2, $iItem ,$iSubitem),"Pass") Then DllStructSetData($tCustDraw, 'clrTextBk', $iColor2) DllStructSetData($tCustDraw, 'clrText', RGB2BGR(0x008000)) EndIf if StringInStr(_GUICtrlListView_GetItemText($hListView2, $iItem ,$iSubitem),"In Progress") Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR(0x000000)) DllStructSetData($tCustDraw, 'clrText', RGB2BGR(0xffd700)) EndIf Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY This works fine with a regular ListView like this : $ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454) But, I need gridlines and checkboxes too, which doesnt work currently: $ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454, BitOR($LVS_REPORT,$LVS_ALIGNLEFT), BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES)) Any workarounds to this? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2013 Moderators Share Posted June 2, 2013 (edited) dragonlord, If you give us some code which we can run then perhaps we might be able to help - but I for one an certainly not writing all the additional code to test the function you posted. M23 Edited June 2, 2013 by Melba23 Typo  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dragonlord Posted June 2, 2013 Author Share Posted June 2, 2013 (edited) Â My bad, here some sample code : expandcollapse popup#include <GuiListView.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("GBC", 1016, 575+20, -1, -1) $hStatus = _GUICtrlStatusBar_Create($Form1_1 ) _GUICtrlStatusBar_SetText($hStatus, "Status") ;~ Hottracking works $ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454) ;~ Hottracking doesnt work ;~ $ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454, BitOR($LVS_REPORT,$LVS_ALIGNLEFT), BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES)) $hListView2 = GUICtrlGetHandle($ListView2) GUICtrlCreateListViewItem("0|Test 1",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlCreateListViewItem("1|test 3",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlCreateListViewItem("2|test 4",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 1, 50) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView2 Switch $iCode Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tInfo, "Item") $iSubItem = DllStructGetData($tInfo, "SubItem") _GUICtrlStatusBar_SetText($hStatus, $iItem &","&$iSubItem ) Case $NM_CUSTOMDRAW If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;' & _ 'dword DrawStage;hwnd hdc;long rect[4];dword ItemSpec;int ItemState;dword Itemlparam;' & _ 'dword clrText;dword clrTextBk;int SubItem;' & _ 'dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText[4];int Align', _ ;winxp or later $lParam), $iDrawStage, $iItem, $iSubitem, $hDC, $iColor1, $iColor2, $iColor3 $iDrawStage = DllStructGetData($tCustDraw, 'DrawStage') If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ;request drawing each cell separately If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT $iItem = DllStructGetData($tCustDraw, 'ItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'SubItem') Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edited June 2, 2013 by dragonlord Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2013 Moderators Share Posted June 2, 2013 dragonlord, Looking at it - I think I may have a workaround. Stay tuned. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted June 2, 2013 Moderators Solution Share Posted June 2, 2013 dragonlord, Better still, I have a solution! Just add the $LVS_EX_FULLROWSELECT style to the ListView and the status bar updates correctly: expandcollapse popup#include <GuiListView.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("GBC", 1016, 575+20, -1, -1) $hStatus = _GUICtrlStatusBar_Create($Form1_1 ) _GUICtrlStatusBar_SetText($hStatus, "Status") ;~ Hottracking works ;$ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454) ;~ Hottracking doesnt work $ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454, BitOR($LVS_REPORT, $LVS_ALIGNLEFT), BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetBkColor($ListView2, 0xCCCCFF) ; I need this to see the gridlines $hListView2 = GUICtrlGetHandle($ListView2) GUICtrlCreateListViewItem("0|Test 1",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlCreateListViewItem("1|test 3",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlCreateListViewItem("2|test 4",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 1, 50) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView2 Switch $iCode Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tInfo, "Item") $iSubItem = DllStructGetData($tInfo, "SubItem") _GUICtrlStatusBar_SetText($hStatus, $iItem &","&$iSubItem ) Case $NM_CUSTOMDRAW If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;' & _ 'dword DrawStage;hwnd hdc;long rect[4];dword ItemSpec;int ItemState;dword Itemlparam;' & _ 'dword clrText;dword clrTextBk;int SubItem;' & _ 'dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText[4];int Align', _ ;winxp or later $lParam), $iDrawStage, $iItem, $iSubitem, $hDC, $iColor1, $iColor2, $iColor3 $iDrawStage = DllStructGetData($tCustDraw, 'DrawStage') If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ;request drawing each cell separately If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT $iItem = DllStructGetData($tCustDraw, 'ItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'SubItem') Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I hope it works for you too. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
dragonlord Posted June 2, 2013 Author Share Posted June 2, 2013 dragonlord, Better still, I have a solution! Just add the $LVS_EX_FULLROWSELECT style to the ListView and the status bar updates correctly: expandcollapse popup#include <GuiListView.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("GBC", 1016, 575+20, -1, -1) $hStatus = _GUICtrlStatusBar_Create($Form1_1 ) _GUICtrlStatusBar_SetText($hStatus, "Status") ;~ Hottracking works ;$ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454) ;~ Hottracking doesnt work $ListView2 = GUICtrlCreateListView(" | ", 16, 108, 986, 454, BitOR($LVS_REPORT, $LVS_ALIGNLEFT), BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetBkColor($ListView2, 0xCCCCFF) ; I need this to see the gridlines $hListView2 = GUICtrlGetHandle($ListView2) GUICtrlCreateListViewItem("0|Test 1",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlCreateListViewItem("1|test 3",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlCreateListViewItem("2|test 4",$ListView2) _GUICtrlListView_SetItemChecked($ListView2, -1, True) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 1, 50) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView2 Switch $iCode Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tInfo, "Item") $iSubItem = DllStructGetData($tInfo, "SubItem") _GUICtrlStatusBar_SetText($hStatus, $iItem &","&$iSubItem ) Case $NM_CUSTOMDRAW If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;' & _ 'dword DrawStage;hwnd hdc;long rect[4];dword ItemSpec;int ItemState;dword Itemlparam;' & _ 'dword clrText;dword clrTextBk;int SubItem;' & _ 'dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText[4];int Align', _ ;winxp or later $lParam), $iDrawStage, $iItem, $iSubitem, $hDC, $iColor1, $iColor2, $iColor3 $iDrawStage = DllStructGetData($tCustDraw, 'DrawStage') If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ;request drawing each cell separately If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT $iItem = DllStructGetData($tCustDraw, 'ItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'SubItem') Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I hope it works for you too. M23 Awesome. Works great. You the man ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now