Что нового

Как убрать стрелку сортировки из заголовка таблицы в ListView?

vovsla

Осваивающий
Сообщения
607
Репутация
36
Как убрать стрелку сортировки из заголовка таблицы в ListView при этом не меняя уже сформировавшийся порядок строк?
За основу можно взять код содержащийся в примере для функции _GUICtrlListView_SortItems
 

Yashied

Модератор
Команда форума
Глобальный модератор
Сообщения
5,379
Репутация
2,724
Для 1-го столбца (индекс 0).

Код:
_GUICtrlHeader_SetItemFormat($hHdr, 0, BitAND(_GUICtrlHeader_GetItemFormat($hHdr, 0), BitNOT(BitOR($HDF_SORTDOWN, $HDF_SORTUP))))
 
Автор
V

vovsla

Осваивающий
Сообщения
607
Репутация
36
почему-то не работает Autoit v3.3.4.0

Код:
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hListView, $hListView2

_Example1()

Func _Example1()
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)

    GUICreate("ListView Sort", 300, 200)

    $hListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $iExListViewStyle)

    ; Load images
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    _AddRow($hListView, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($hListView, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($hListView, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState()

    _GUICtrlListView_RegisterSortCallBack($hListView)

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hListView
                ; Kick off the sort callback
                _GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView))
			EndSwitch
;~ 							Sleep(100)
		_GUICtrlHeader_SetItemFormat($hListView, 1, BitAND(_GUICtrlHeader_GetItemFormat($hListView, 1), BitNOT(BitOR($HDF_SORTDOWN, $HDF_SORTUP))))
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($hListView)
    GUIDelete()
EndFunc   ;==>_Example1


Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
EndFunc   ;==>_AddRow

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2

    $hWndListView = $hListView
    $hWndListView2 = $hListView2
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    If Not IsHWnd($hListView2) Then $hWndListView2 = GUICtrlGetHandle($hListView2)
    
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView, $hWndListView2
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)

                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Предупреждение За нарушение правил форума (пункт В.11):
Любые отрывки AutoIt кода необходимо заключать в тег [autoit]
autoit.gif
(подробнее), а обычный код соответственно в тег [code]
code.gif
(подробнее). Также большие выдержки текста помещайте под тег [spoiler]
spoiler.gif
(подробнее), там где это поддерживается естественно. Как в случае с названием темы, также короткое и эргономичное сообщение привлекает больше внимания, и шансы на получение конкретного ответа увеличиваются.


С уважением, ваш Модератор.
 

Yashied

Модератор
Команда форума
Глобальный модератор
Сообщения
5,379
Репутация
2,724
Vovsla сказал(а):
почему-то не работает Autoit v3.3.4.0

Потому что нужно все-таки было немного наморщить ум и заглянуть в справку.

Код:
_GUICtrlHeader_SetItemFormat(_GUICtrlListView_GetHeader($hListView), 1, BitAND(_GUICtrlHeader_GetItemFormat(_GUICtrlListView_GetHeader($hListView), 1), BitNOT(BitOR($HDF_SORTDOWN, $HDF_SORTUP))))
 
Верх