Jump to content

Recommended Posts

Posted

 I just wana try to use:

https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvgroupmetrics

As so far I got:

#AutoIt3Wrapper_UseX64=N

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

; https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvgroupmetrics
Global Const $tagLVGROUPMETRICS = _
        "uint cbSize;" & _
        "uint mask;" & _
        "uint Left;" & _
        "uint Top;" & _
        "uint Right;" & _
        "uint Bottom;" & _
        "COLORREF crLeft;" & _
        "COLORREF crTop;" & _
        "COLORREF crRight;" & _
        "COLORREF crBottom;" & _
        "COLORREF crHeader;" & _
        "COLORREF crFooter;"

Global Const $LVGMF_BORDERSIZE = 0x00000001
Global Const $LVGMF_BORDERCOLOR = 0x00000002
Global Const $LVGMF_TEXTCOLOR = 0x00000004

_Example()

Func _Example()

    ; GUI
    Local $hGUI = GUICreate("Windows 11 LVGROUPMETRICS", 900, 500)
    #forceref $hGUI

    Local $idLV = GUICtrlCreateListView( _
            "Name|Description|State", _
            10, 10, 880, 440, _
            BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))

    Local $hLV = GUICtrlGetHandle($idLV)

    ; Explorer theme (Win11)
    DllCall("uxtheme.dll", "none", "SetWindowTheme", _
            "hwnd", $hLV, _
            "wstr", "Explorer", _
            "ptr", 0)

    ; Extended styles
    _GUICtrlListView_SetExtendedListViewStyle($hLV, _
            BitOR($LVS_EX_FULLROWSELECT, _
            $LVS_EX_DOUBLEBUFFER, _
            $LVS_EX_BORDERSELECT))

    ; Group view
    _GUICtrlListView_EnableGroupView($hLV, True)

    ; Groups
    _GUICtrlListView_InsertGroup($hLV, 0, 100, "Applications")
    _GUICtrlListView_InsertGroup($hLV, 1, 200, "Services")

    ; Items
    Local $i

    $i = _GUICtrlListView_AddItem($hLV, "Explorer.exe")
    _GUICtrlListView_AddSubItem($hLV, $i, "Windows Shell", 1)
    _GUICtrlListView_AddSubItem($hLV, $i, "Running", 2)
    _GUICtrlListView_SetItemGroupID($hLV, $i, 100)

    $i = _GUICtrlListView_AddItem($hLV, "Notepad.exe")
    _GUICtrlListView_AddSubItem($hLV, $i, "Text Editor", 1)
    _GUICtrlListView_AddSubItem($hLV, $i, "Idle", 2)
    _GUICtrlListView_SetItemGroupID($hLV, $i, 100)

    $i = _GUICtrlListView_AddItem($hLV, "AudioSrv")
    _GUICtrlListView_AddSubItem($hLV, $i, "Windows Audio", 1)
    _GUICtrlListView_AddSubItem($hLV, $i, "Active", 2)
    _GUICtrlListView_SetItemGroupID($hLV, $i, 200)

    #Region ; LVGROUPMETRICS

    Local $tMetrics = DllStructCreate($tagLVGROUPMETRICS)

    DllStructSetData($tMetrics, "cbSize", DllStructGetSize($tMetrics))

    DllStructSetData($tMetrics, "mask", _
            BitOR($LVGMF_BORDERSIZE, _
            $LVGMF_BORDERCOLOR, _
            $LVGMF_TEXTCOLOR))

    ; Margins
    DllStructSetData($tMetrics, "Left", 12)
    DllStructSetData($tMetrics, "Top", 8)
    DllStructSetData($tMetrics, "Right", 12)
    DllStructSetData($tMetrics, "Bottom", 8)

    ; Border colors
    DllStructSetData($tMetrics, "crLeft", 0xFFD0D0)
    DllStructSetData($tMetrics, "crTop", 0xD0FFD0)
    DllStructSetData($tMetrics, "crRight", 0xD0D0FF)
    DllStructSetData($tMetrics, "crBottom", 0xD0D0D0)

    ; Header text color (BGR)
    DllStructSetData($tMetrics, "crHeader", 0xFF0000)

    ; Footer text color (BGR)
    ; RGB(0,128,0)
    DllStructSetData($tMetrics, "crFooter", 0x00FF00)

    #EndRegion ; LVGROUPMETRICS

    ; ----------------------------
    ; Apply metrics
    ; ----------------------------
    Local $bRet = _GUICtrlListView_SetGroupMetrics($hLV, $tMetrics)

    ConsoleWrite("SetGroupMetrics: " & $bRet & @CRLF)

    ; ----------------------------
    ; Column widths
    ; ----------------------------
    _GUICtrlListView_SetColumnWidth($hLV, 0, 220)
    _GUICtrlListView_SetColumnWidth($hLV, 1, 350)
    _GUICtrlListView_SetColumnWidth($hLV, 2, 120)

    GUISetState(@SW_SHOW)

    While True
        Switch GUIGetMsg()

            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

EndFunc   ;==>_Example

Func _GUICtrlListView_SetGroupMetrics($hWnd, $pMetrics)

    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
    EndIf

    If $hWnd = 0 Then
        Return SetError(1, 0, False)
    EndIf

    If Not IsDllStruct($pMetrics) Then
        Return SetError(2, 0, False)
    EndIf

    Return _SendMessage( _
            $hWnd, _
            $LVM_SETGROUPMETRICS, _
            0, _
            DllStructGetPtr($pMetrics), _
            0, _
            "ptr")

EndFunc   ;==>_GUICtrlListView_SetGroupMetrics

of course most features are: Not implemented by MS :(

 

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

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...