Jump to content

Change in _GUICtrlListView_GetViewDetails?


Danp2
 Share

Recommended Posts

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:

Func 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

Link to comment
Share on other sites

  • Moderators

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_GetViewDetails
If my suspicions are correct that should now work as expected :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

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! :D

I will alter the function for the next release - thanks for reporting the problem. :)

M23

Edit: And done. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...