Danp2 Posted September 7, 2014 Posted September 7, 2014 Hi All, I recently noticed when recompiling an older script that the listview row coloration was no longer functioning as expected. I have narrowed it down to this line in my WM_NOTIFY routine: If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG If I comment out the line, the the alternating row coloration works as expected. Is this line no longer needed, or has something changed / broken in the newer versions of Autoit? Tested with 3.3.12.0 and 3.3.13.19. Here's the complete WM_NOTIFY function: expandcollapse popupFunc WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR Local Const $iListBkColor = 0xFFFFFF Local Const $iListAltBkColor = 0xFFF68F Local Const $iListSelColor = 0x00BFFF ;custom draw constants Local Const $CDDS_ITEM = 0x10000 Local Const $CDDS_MAPPART = 0x5 Local Const $CDDS_POSTERASE = 0x4 Local Const $CDDS_POSTPAINT = 0x2 Local Const $CDDS_PREERASE = 0x3 Local Const $CDDS_PREPAINT = 0x1 Local Const $CDDS_SUBITEM = 0x20000 Local Const $CDDS_ITEMPOSTERASE = BitOR($CDDS_ITEM, $CDDS_POSTERASE) Local Const $CDDS_ITEMPOSTPAINT = BitOR($CDDS_ITEM, $CDDS_POSTPAINT) Local Const $CDDS_ITEMPREERASE = BitOR($CDDS_ITEM, $CDDS_PREERASE) Local Const $CDDS_ITEMPREPAINT = BitOR($CDDS_ITEM, $CDDS_PREPAINT) Local Const $CDRF_DODEFAULT = 0x0 Local Const $CDRF_NEWFONT = 0x2 Local Const $CDRF_NOTIFYITEMDRAW = 0x20 Local Const $CDRF_NOTIFYPOSTERASE = 0x40 Local Const $CDRF_NOTIFYPOSTPAINT = 0x10 Local Const $CDRF_NOTIFYSUBITEMDRAW = 0x20 Local Const $CDRF_SKIPDEFAULT = 0x4 $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $LVN_BEGINDRAG ; Disallow drag operation Return 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') If Mod($iItem, 2) = 0 Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($iListAltBkColor)) Else DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($iListBkColor)) EndIf Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Thoughts? Thx, Dan Latest Webdriver UDF Release Webdriver Wiki FAQs
Moderators Melba23 Posted September 7, 2014 Moderators Posted September 7, 2014 Danp2,The constants used to determine the view were found to be wrongly set earlier this year. I have a feeling that when they were changed to the correct values the return from that particular function as not altered to match the new value of the relevant constant. Can you please use this modified function instead and let me know if the problem goes away:Func _GUICtrlListView_GetViewDetails_Mod($hWnd) Return _GUICtrlListView_GetView($hWnd) = $LV_VIEW_DETAILS ; Use constant and not magic number EndFunc ;==>_GUICtrlListView_GetViewDetailsIf my suspicions are correct that should now work as expected 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
Danp2 Posted September 7, 2014 Author Posted September 7, 2014 Yes... that changed fixed it. Latest Webdriver UDF Release Webdriver Wiki FAQs
Moderators Melba23 Posted September 7, 2014 Moderators Posted September 7, 2014 (edited) Danp2,Excellent - the crystal ball is working well today. A very good example of why you should use constants and not magic numbers - guinness will be pleased! I will alter the function for the next release - thanks for reporting the problem. M23Edit: And done. Edited September 7, 2014 by Melba23 Mat and mLipok 2 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
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