Jump to content

_GUICtrlListView_InsertGroup - a question about $iIndex and $iGroupID paramater


Recommended Posts

Posted

I need $LVS_SINGLESEL

Yours solution automatically select all rows when I clicked the GroupHeader

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted
2 hours ago, mLipok said:

How to use WM_NOTIFY to detect which ROW ITEM is selected after you click GROUP HEADER and the focus switched from GROUP ITEM to the first ROW ITEM in the GROUP ?

I managed to create such a temporary solution

#include <GUIConstants.au3>
#include <GuiListView.au3>

Global $_hGUI = 0, $_hListView = 00
Global $_iListView_LastClickedRow = -1
Example()

Func Example()
    ; create GUI window
    $_hGUI = GUICreate("Example", 500, 800)
    ; create ListView control
    Local $idListview = GUICtrlCreateListView("", 10, 10, 480, 780, BitOR($LVS_SINGLESEL, 0))
    $_hListView = ControlGetHandle($_hGUI, '', $idListview)

    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Set ANSI format
;~     _GUICtrlListView_SetUnicodeFormat($idListview, False)

    _GUICtrlListView_BeginUpdate($idListview)

    _GUICtrlListView_AddColumn($idListview, "Column 0", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)

    Local $iMAX = 499
    For $i = 0 To $iMAX
        _GUICtrlListView_AddItem($idListview, "Row " & $i & ": Col 0", 0)
        _GUICtrlListView_AddSubItem($idListview, $i, "Row " & $i & ": Col 1", 1)
    Next

    Local $iCount10 = 0, $iGroupID
    For $i = 0 To $iMAX
        If Mod($i, 10) = 0 Then
            $iGroupID = $iCount10 * 10
            $iCount10 += 1
            _GUICtrlListView_InsertGroup($idListview, -1, $iGroupID, 'GroupID=' & $iGroupID & ' for all rows with RowIndex in range <' & $iGroupID & ',' & ($iCount10 * 10) - 1 & '>')
        EndIf
        _GUICtrlListView_SetItemGroupID($idListview, $i, $iGroupID)
    Next

    _GUICtrlListView_EnableGroupView($idListview)

    _GUICtrlListView_EnsureVisible($idListview, 250)
    _GUICtrlListView_EndUpdate($idListview)
    GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY)

    Local $aInfo, $s_GroupHeader

;~  $aInfo = _GUICtrlListView_GetGroupInfo($idListview, 240)
    $aInfo = _GUICtrlListView_GetGroupInfoByIndex($idListview, 24) ; REMARK: 0based ListView Index  24 is $sGroupHumanIndex = "[ #25 ]"
    $s_GroupHeader = $aInfo[0] ; please note that $s_GroupHeader does not contain an index in the displayed form [ #**** ]
    MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Focus on $sGroupHumanIndex = "[ #25 ]" ' & @CRLF & 'Is it like following:' & @CRLF & $s_GroupHeader & @CRLF & 'It will be removed !')

    ; removing group for all 24* rows
    _GUICtrlListView_RemoveGroup($idListview, 240)

;~  $aInfo = _GUICtrlListView_GetGroupInfo($idListview, 250)
    $aInfo = _GUICtrlListView_GetGroupInfoByIndex($idListview, 24) ; REMARK: 0based ListView Index  24 is $sGroupHumanIndex = "[ #25 ]"
    $s_GroupHeader = $aInfo[0] ; please note that $s_GroupHeader does not contain an index in the displayed form [ #**** ]
    MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, 'Where is $sGroupHumanIndex = "[ #25 ]" GroupID=240 ?' & @CRLF & 'Was it removed ?' & @CRLF & @CRLF & 'What content is in $sGroupHumanIndex = "[ #25 ]" ?' & @CRLF & 'Is it like following:' & @CRLF & $s_GroupHeader)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam

    If $hWnd = $_hGUI Then ; check if Our GUI - in case you create multiple GUI - Window
        Local $tItem = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
        If $tItem.hWndFrom = $_hListView Then     ; check if our ListView - in case you have few ListView on the same GUI - Window
            Local $iItemSpec = $tItem.dwItemSpec ; ItemIndex for "RowElement", GroupID for "GroupElement"
;~          If $tItem.Code = $NM_SETFOCUS Or $tItem.Code = $NM_HOVER Or $tItem.Code = $NM_SETCURSOR Or $tItem.Code = $NM_CLICK Or $tItem.Code = $NM_DBLCLK Or $tItem.Code = $NM_RCLICK Or $tItem.Code = $NM_RDBLCLK Then
            If $tItem.uItemState = $CDIS_SELECTED Or $tItem.Code = $NM_CLICK Or $tItem.Code = $NM_DBLCLK Or $tItem.Code = $NM_RCLICK Or $tItem.Code = $NM_RDBLCLK Then
                $_iListView_LastClickedRow = _GUICtrlListView_GetSelectionMark($_hListView)
                ConsoleWrite('! 1. $_iListView_LastClickedRow= ' & $_iListView_LastClickedRow & @CRLF)
;~              ConsoleWrite('! 1. Selection Mark = ' &  & @CRLF)
;~              ConsoleWrite('! 2. $iItemSpec= ' & $iItemSpec & ' $tItem.dwItemType=' & $tItem.dwItemType & @CRLF)
                Return $GUI_RUNDEFMSG
            EndIf
            If $tItem.dwItemType = $LVCDI_ITEM Then
            ElseIf $tItem.dwItemType = $LVCDI_GROUP Then
                If $tItem.Code = $NM_SETFOCUS Or $tItem.Code = $NM_HOVER Or $tItem.Code = $NM_SETCURSOR Or $tItem.Code = $NM_CLICK Or $tItem.Code = $NM_DBLCLK Or $tItem.Code = $NM_RCLICK Or $tItem.Code = $NM_RDBLCLK Then
                    ConsoleWrite('! 3. Selection Mark = ' & _GUICtrlListView_GetSelectionMark($_hListView) & @CRLF)
;~                  ConsoleWrite('! 4. $iItemSpec= ' & $iItemSpec & @CRLF)
                    Return $GUI_RUNDEFMSG
                ElseIf $tItem.Code = $NM_CUSTOMDRAW And $tItem.dwDrawStage = $CDDS_POSTPAINT Then
;~              ConsoleWrite('! PRE. Selection Mark = ' & _GUICtrlListView_GetSelectionMark($_hListView) & @CRLF)
                    Local $iTemp_Row = _GUICtrlListView_GetSelectionMark($_hListView)
                    If $_iListView_LastClickedRow <> $iTemp_Row Then
                        $_iListView_LastClickedRow = $iTemp_Row
                        ConsoleWrite('! 7. $_iListView_LastClickedRow= ' & $_iListView_LastClickedRow & @CRLF)
                    EndIf

;~                  ConsoleWrite("! $iItemSpec=" & $iItemSpec & " $tItem.Code=" & $tItem.Code & @CRLF)
;~                  ConsoleWrite('! 5. Selection Mark = ' & _GUICtrlListView_GetSelectionMark($_hListView) & @CRLF)
;~                  ConsoleWrite('! 6. $iItemSpec= ' & $iItemSpec & @CRLF)
                ElseIf $tItem.Code = $NM_CUSTOMDRAW And $tItem.dwDrawStage = $CDDS_PREPAINT Then
;~              ConsoleWrite('! POST. Selection Mark = ' & _GUICtrlListView_GetSelectionMark($_hListView) & @CRLF)

                    Local $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tItem, "left"))

                    #Region ; create full row background (black) with a leading line (red)
                    $tRect.bottom = $tRect.top + 16
                    Local $hBrush = _WinAPI_CreateSolidBrush(0)
                    _WinAPI_FillRect($tItem.HDC, $tRect, $hBrush)
                    _WinAPI_DeleteObject($hBrush)
                    Local $hPen = _WinAPI_CreatePen($PS_SOLID, 1, _WinAPI_SwitchColor(0xFF0000)) ; RGB to BGR
                    Local $oOrig = _WinAPI_SelectObject($tItem.HDC, $hPen)
                    _WinAPI_DrawLine($tItem.HDC, $tRect.left + 5, $tRect.top + 8, $tRect.right - 5, $tRect.top + 8)
                    _WinAPI_SelectObject($tItem.HDC, $oOrig)
                    _WinAPI_DeleteObject($hPen)
                    Local $aGroup = _GUICtrlListView_GetGroupInfo($tItem.hWndFrom, $iItemSpec)
                    #EndRegion ; create full row background (black) with a leading line (red)

                    #Region ; PREFIX Group with auto INDEX - text with your own color (dark grey) and your own background (light grey) - on the previously created full row background
                    Local $iGroupIndex_0based = _GUICtrlListView_GetGroupIndexByGroupID($_hListView, $iItemSpec) ; auto count Group Index
                    Local $sGroupHumanIndex = "[ #" & $iGroupIndex_0based + 1 & ' ]'

                    $tRect.left += 10
                    _WinAPI_SetBkColor($tItem.HDC, _WinAPI_SwitchColor(0xAAAAAA)) ; RGB to BGR
                    _WinAPI_SetBkMode($tItem.HDC, $OPAQUE)
                    _WinAPI_SetTextColor($tItem.HDC, _WinAPI_SwitchColor(0x880000)) ; RGB to BGR
                    _WinAPI_DrawText($tItem.HDC, $sGroupHumanIndex, $tRect, $DT_LEFT)
                    #EndRegion ; PREFIX Group with auto INDEX - text with your own color (dark grey) and your own background (light grey) - on the previously created full row background

                    #Region ; repaint the text with your own color (dark blue) and your own background (light blue) - on the previously created full row background
                    $tRect.left += 80
                    _WinAPI_SetBkColor($tItem.HDC, _WinAPI_SwitchColor(0x55AAFF)) ; RGB to BGR
                    _WinAPI_SetBkMode($tItem.HDC, $OPAQUE)
                    _WinAPI_SetTextColor($tItem.HDC, _WinAPI_SwitchColor(0x0000FF)) ; RGB to BGR
                    _WinAPI_DrawText($tItem.HDC, "  " & $aGroup[0] & "  ", $tRect, $DT_LEFT)
                    #EndRegion ; repaint the text with your own color (dark blue) and your own background (light blue) - on the previously created full row background

                    Return $CDRF_SKIPDEFAULT
                EndIf
            EndIf
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _GUICtrlListView_GetGroupIndexByGroupID($hWnd, $iGroupID)
    Local $iMaxIndex = _GUICtrlListView_GetGroupCount($hWnd) - 1
    Local $aInfo
    For $i = 0 To $iMaxIndex
        $aInfo = _GUICtrlListView_GetGroupInfoByIndex($hWnd, $i)
        If $aInfo[2] = $iGroupID Then Return $i
    Next

    Return SetError(1, 0, -1)
EndFunc   ;==>_GUICtrlListView_GetGroupIndexByGroupID

the main idea is here:

ElseIf $tItem.dwItemType = $LVCDI_GROUP Then
    ......
    ElseIf $tItem.Code = $NM_CUSTOMDRAW And $tItem.dwDrawStage = $CDDS_POSTPAINT Then
        Local $iTemp_Row = _GUICtrlListView_GetSelectionMark($_hListView)
        If $_iListView_LastClickedRow <> $iTemp_Row Then
            $_iListView_LastClickedRow = $iTemp_Row
            ConsoleWrite('! 7. $_iListView_LastClickedRow= ' & $_iListView_LastClickedRow & @CRLF)
        EndIf
......

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted (edited)
11 hours ago, argumentum said:
11 hours ago, mLipok said:

Should I use Return $GUI_RUNDEFMSG at the end of:

.....
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

?

I would. There's no reason not to. Plus, is good manners :) 

Yes, agree this is a good idea :). There's really 3 options for windows messages:

  • Return _WinAPI_DefSubclassProc() (Next handler in the chain - i.e. AutoIt's handler) - This is probably what "Return $GUI_RUNDEFMSG" effectively does...
  • Return _WinAPI_DefWindowProcW() (The default windows handler)
  • Return some value (When we've handled the message, and don't want windows/autoit do do anything more.)

We'll hit that bottom line when we're not handling the WM_NOTIFY message (e.g. its not from our listview, or its not a NM_CUSTOMDRAW).  So in those cases we should send the message someplace else for processing.

Edited by MattyD
Posted

:unsure:

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $b_CUSTOM_DRAW =  True

Example()

Func Example()
    Local $hGUI = GUICreate("AutoIt Advanced ListView", 500, 400)
    Local $idListview = GUICtrlCreateListView("", 10, 10, 480, 380)

   ; ENABLE DOUBLE BUFFER ??
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))

    _GUICtrlListView_AddColumn($idListview, "Tasks", 350)
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_SetView($idListview, 1)

    GUISetState()

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Creating Groups
    Local $iRed   = _GroupManager(-1, $idListview, "EMERGENCY", 0, 0xFFCCCC, 0xAA0000)
    Local $iBlue  = _GroupManager(-1, $idListview, "ON WAIT", 0, 0xCCE5FF, 0x004080)
    ConsoleWrite("$iBlue=" & $iBlue & @CRLF)

    ; Add Items
    _AddItemToGroup($idListview, "Bug Fix #104", $iRed)
    _AddItemToGroup($idListview, "Manual book update", $iBlue)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GroupManager($iRed, $idListview, "EMERGENCY", 0, 0xFF0000, 0xffffff)
    _GroupManager($iBlue, $idListview, "ON WAIT", 0, 0x007DFF, 0xffffff)
    Sleep(3000)

EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _GroupManager
; Description....: Handles creation, update, and retrieval of ListView groups and their custom colors.
; Parameters.....: $iID      - Group ID. Use -1 for creation.
;                  $hWnd     - ListView Handle or ID (required for Create/Update, 0 for Retrieve).
;                  $sHdr     - Group Header text.
;                  $iAlgn    - Text alignment (0=Left, 1=Center, 2=Right).
;                  $iBk      - Background color (Hex).
;                  $iTxt     - Text color (Hex).
; Return values..: If creation: Integer (New ID). If retrieval: Array [Header, Align, BkColor, TextColor].
; ===============================================================================================================================
Func _GroupManager($iID = -1, $hWnd = 0, $sHdr = "", $iAlgn = 0, $iBk = 0xAAAAA0, $iTxt = 0xAA0000)
    Static $aD[1][4], $iNext = 1
    Local $bNew = False

    ; Creation Handling ($iID = -1)
    If $iID = -1 And $hWnd <> 0 Then
        $iID = $iNext
        ReDim $aD[$iNext + 1][4]
        $iNext += 1
        $bNew = True ; Flag for new registration
    EndIf

    If $iID <= 0 Or $iID >= UBound($aD) Then Return SetError(1, 0, 0)

    ; Data Storage (Create OR Update)
    If $hWnd <> 0 Then
        $aD[$iID][0] = $sHdr
        $aD[$iID][1] = $iAlgn
        $aD[$iID][2] = $iBk
        $aD[$iID][3] = $iTxt

        If $bNew Then
            _GUICtrlListView_InsertGroup($hWnd, -1, $iID, $sHdr, $iAlgn)
        Else
            _GUICtrlListView_SetGroupInfo($hWnd, $iID, $sHdr, $iAlgn)
        EndIf
    EndIf

    ; Return Logic
    If $bNew Then Return $iID
    Local $aR[4] = [$aD[$iID][0], $aD[$iID][1], $aD[$iID][2], $aD[$iID][3]]
    Return $aR
EndFunc

Func _AddItemToGroup($hWnd, $sText, $iGroupID)
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $sText)
    _GUICtrlListView_SetItemGroupID($hWnd, $iIndex, $iGroupID)
    Return $iIndex
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    If $tNMHDR.Code = $NM_CUSTOMDRAW Then
        Local $tItem = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
        If $b_CUSTOM_DRAW And $tItem.dwItemType = $LVCDI_GROUP And $tItem.dwDrawStage = $CDDS_PREPAINT Then
            Local $aInfo = _GroupManager($tItem.dwItemSpec)
            If IsArray($aInfo) Then
                _WinAPI_SetBkColor($tItem.HDC, _WinAPI_SwitchColor($aInfo[2]))
                _WinAPI_SetBkMode($tItem.HDC, $OPAQUE)
                _WinAPI_SetTextColor($tItem.HDC, _WinAPI_SwitchColor($aInfo[3]))
                Local $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tItem, "left"))
                _WinAPI_DrawText($tItem.HDC, $aInfo[0], $tRect, $DT_LEFT)
                Return $CDRF_SKIPDEFAULT
            EndIf
        EndIf
    EndIf
    Return 0
EndFunc

 

I know that I know nothing

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
×
×
  • Create New...