Sign in to follow this  
Followers 0
HolmesShelock

Justifying column header and text differently in a ListView

4 posts in this topic

_GUICtrlListView_JustifyColumn() justifies column header and text of a ListView in the same way. But, is there any means to achieve different alignment, e.g. "Centered" for header and "Right" for text?


[size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size]

Share this post


Link to post
Share on other sites



HolmesShelock,

A bit long-winded, but it does what you want - and as you can see you can still click on the header to sort if required: ;)

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

Global $aTitles[3] = ["Col 0", "Col 1", "Col 2"]
Global $vSortSense_Full = True, $vSortSense_Item = True

$hGUI = GUICreate("Test", 500, 500)

$cLV_Full = GUICtrlCreateListView("", 10, 10, 480, 200)
$hLV_Full = GUICtrlGetHandle($cLV_Full)

$cLv_Header = GUICtrlCreateListView("", 10, 250, 480, 25)
$cLV_Items = GUICtrlCreateListView("", 10, 275, 480, 175, $LVS_NOCOLUMNHEADER)
$hLV_Header = GUICtrlGetHandle($cLv_Header)
$hLV_Items = GUICtrlGetHandle($cLV_Items)


For $i = 0 To 2
    _GUICtrlListView_AddColumn($cLV_Full, $aTitles[$i], 150)
    _GUICtrlListView_AddColumn($cLv_Header, $aTitles[$i], 150, 1)
    _GUICtrlListView_AddColumn($cLV_Items, $aTitles[$i], 150, 2)
Next

For $i = 0 To 4
    $sData = ""
    For $j = 0 To 2
        $sData &= "Item " & $i & "-" & Random(0, 100, 1) & "|"
    Next
    StringTrimRight($sData, 1)
    GUICtrlCreateListViewItem($sData, $cLV_Full)
    GUICtrlCreateListViewItem($sData, $cLV_Items)
Next

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $iCode
        Case $LVN_COLUMNCLICK ; A column was clicked
            Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
            Switch $hWndFrom
                Case $hLV_Full
                    _GUICtrlListView_SimpleSort($hLV_Full, $vSortSense_Full, DllStructGetData($tInfo, "SubItem"))
                Case $hLV_Header
                    _GUICtrlListView_SimpleSort($hLV_Items, $vSortSense_Item, DllStructGetData($tInfo, "SubItem")
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    
EndFunc   ;==>_WM_NOTIFY
Any use? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Any use? :)

 

Typo detected 

_GUICtrlListView_SimpleSort($hLV_Items, $vSortSense_Item, DllStructGetData($tInfo, "SubItem")

should be

_GUICtrlListView_SimpleSort($hLV_Items, $vSortSense_Item, DllStructGetData($tInfo, "SubItem"))

And did you try resizing the columns of teh table below? Scrollbar appears in the header itself!


[size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size]

Share this post


Link to post
Share on other sites

HolmesShelock,

Any use?

Obviously not. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0