Jump to content

Recommended Posts

Posted

_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]

  • Moderators
Posted

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

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:

  Reveal hidden contents

 

Posted
  On 12/30/2014 at 9:48 AM, Melba23 said:

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]

  • Moderators
Posted

HolmesShelock,

  Quote

Any use?

Obviously not. :(

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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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