Jump to content

Migrate to GUIListViewEx problems with coloumn colors


Efo74
 Share

Recommended Posts

Hi, I want to migrate to the GUIListViewEx library but I'm having problems applying colors for a column. Example 1 is done without the library (but that's how I want it). In example 2, in addition to missing the color for the column, the white grid on the table is also missing. Can someone help me ? Thank You .

Ex1.au3 Ex2.au3

:rolleyes:

Link to comment
Share on other sites

  • Moderators

Efo74,

Please post about problem with any of my UDFs in the UDF thread - I am certain to see it then.

Here is your script working with the UDF:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>

Global $lw_col2 = "0xCECBCE"
Global $lw_col1 = "0xAAAAAA"

Global $alw_colors = _ReturnColors_Array()

$hGUI = GUICreate("Test", 470, 300, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS))

Global $lw_frm_Test1 = GUICtrlCreateListView("", 10, 10, 450, 270)
; Set Ext Styles like this, not in the creation call
_GUICtrlListView_SetExtendedListViewStyle($lw_frm_Test1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))

_GUICtrlListView_AddColumn($lw_frm_Test1, "COL1", 80) ;0
_GUICtrlListView_AddColumn($lw_frm_Test1, "COL2", 320) ;1
_GUICtrlListView_AddColumn($lw_frm_Test1, "*", 17) ;2

_GUICtrlListView_SetBkColor($lw_frm_Test1, Dec(StringTrimLeft($lw_col1, 2)))

GUICtrlSetFont($lw_frm_Test1, 11, 800, 1)

Local $aRecord[10][3]
For $i = 0 To 9
    For $j = 0 To 2
        $aRecord[$i][$j] = $i & " - " & $j
    Next
Next

$iListviewIndex_lw_Example = _GUIListViewEx_Init($lw_frm_Test1, "", 0, 0xFFFFFF, False, 32 + 512) ;if 32+512 program crash

_GUIListViewEx_SetEditStatus($iListviewIndex_lw_Example, 1, 1)

_GUIListViewEx_EditWidth($iListviewIndex_lw_Example, 400)

For $i = 0 To UBound($aRecord) - 1

    $sRecord = $aRecord[$i][0] & "|" & $aRecord[$i][1] & "|"
    ; Use UDF function to add items
    _GUIListViewEx_InsertSpec($iListviewIndex_lw_Example, -1, $sRecord)

Next

; Get current colour array for the ListView - that way we know it is the right size
Global $aLVCol = _GUIListViewEx_ReturnArray($iListviewIndex_lw_Example, 2)
; Now set the colours we want
For $i = 0 To UBound($aLVCol) - 1
    ; Colour alternate lines
    If Mod($i,2) Then
        $aLVCol[$i][0] = ";" & $lw_col1
        $aLVCol[$i][1] = ";" & $lw_col1
    Else
        $aLVCol[$i][0] = ";" & $lw_col2
        $aLVCol[$i][1] = ";" & $lw_col2
    EndIf
    ; Add solid block with selected colour
    $aLVCol[$i][2] = ";0x" & Hex($alw_colors[$i], 6)
Next
; And load it
_GUIListViewEx_LoadColour($iListviewIndex_lw_Example, $aLVCol)

; When using colours, this must come BEFORE the GUISetState call
_GUIListViewEx_MsgRegister()

GUISetState()

While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

    $vRet = _GUIListViewEx_EventMonitor(0) ; Use combos to change EditMode
    Switch @extended
        Case 0
            ; No event detected
        Case 1
            If $vRet = "" Then
                MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF)
            Else
                _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8)
            EndIf
        Case 2
            If $vRet = "" Then
                MsgBox($MB_SYSTEMMODAL, "Header edit", "Header edit aborted" & @CRLF)
            Else
                _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " header edited", Default, 8)
            EndIf
        Case 3
            MsgBox($MB_SYSTEMMODAL, "Sorted", "ListView: " & $vRet & @CRLF)
        Case 4
            ToolTip("")
            MsgBox($MB_SYSTEMMODAL, "Dragged", "From : To" & @CRLF & $vRet & @CRLF)
    EndSwitch

WEnd
;**************************************************************************************************************************************
Func _ReturnColors_Array()
    ;**************************************************************************************************************************************
    Local $aColors_Func[21] = [$COLOR_AQUA, $COLOR_BLACK, $COLOR_BLUE, $COLOR_CREAM, $COLOR_FUCHSIA, $COLOR_GRAY, $COLOR_GREEN, $COLOR_LIME, $COLOR_MAROON, $COLOR_MEDBLUE, $COLOR_MEDGRAY, _
            $COLOR_MONEYGREEN, $COLOR_NAVY, $COLOR_OLIVE, $COLOR_PURPLE, $COLOR_RED, $COLOR_SILVER, $COLOR_SKYBLUE, $COLOR_TEAL, $COLOR_WHITE, $COLOR_YELLOW]
    Return $aColors_Func
EndFunc   ;==>_ReturnColors_Array

I have added a few comments. Please ask if you have any questions.

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

Efo74.

Delighted i could help.

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...