Войти

Показать полную графическую версию : [решено] GUICtrlCreateListView - фиксированная длина колонок


-TRM-
26-11-2018, 19:21
Приветствую, возможно ли сделать фиксированную длину колонок, чтобы пользователь не мог раздвигать колонки?

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

$Debug_LV = False ; Проверяет ClassName передаваемый в ListView функции. Установите True и используйте дескриптор от другого элемента, чтобы увидеть как это работает

_Main()

Func _Main()
Local $hListView

GUICreate("ListView - Вставляет колонки", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState()

; Вставляет колонки
_GUICtrlListView_InsertColumn($hListView, 0, "Колонка 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Колонка 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Колонка 3", 100)

; Цикл выполняется, пока окно не будет закрыто
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main

Creat0R
28-11-2018, 10:11
Можно:

#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIListView.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <WindowsConstants.au3>

$hGUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)('GUICtrlListView Example', 420, 240)

$hListView = GUICtrlCreateListView (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateListView.htm)('Column1|Column2|Column3|Column4', 20, 20, 380, 200, $LVS_NOSORTHEADER)

GUICtrlCreateListViewItem (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateListViewItem.htm)('Item 1|SubItem 1_1|SubItem 1_2|SubItem 1_3', $hListView)
GUICtrlCreateListViewItem (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateListViewItem.htm)('Item 2|SubItem 2_1|SubItem 2_2|SubItem 2_3', $hListView)

_GUICtrlListView_SetColumnWidth (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_SetColumnWidth.htm)($hListView, 0, 80)
_GUICtrlListView_SetColumnWidth (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_SetColumnWidth.htm)($hListView, 1, 80)

GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_SHOW (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_show), $hGUI)
GUIRegisterMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIRegisterMsg.htm)($WM_NOTIFY, '__WM_NOTIFY')

While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) __WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $stTagNMHDR = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)('uint_ptr hWndFrom;uint_ptr iIDFrom;int iCode;uint_ptr iItem;uint_ptr iButton;ptr pitem', $lParam)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) @error (http://www.autoitscript.com/autoit3/docs/macros.htm#@error) Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $GUI_RUNDEFMSG

Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $iCode = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($stTagNMHDR, 'iCode')

Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $iCode
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $HDN_ITEMCHANGING, $HDN_ITEMCHANGINGW
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) 1 ;Prevent draging the item
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)

Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $GUI_RUNDEFMSG
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)

-TRM-
28-11-2018, 13:55
Creat0R, Понимаю что не по теме, но прежде чем создавать новую-возможно ли определенные колонки просто спрятать от глаз пользователя, но чтобы возможно было с них считывать информацию? Или лучше использовать ваш пример и _GUICtrlListView_HideColumn ?

Creat0R
28-11-2018, 22:53
возможно ли определенные колонки просто спрятать от глаз пользователя, но чтобы возможно было с них считывать информацию? »
Возможно.

Или лучше использовать ваш пример и _GUICtrlListView_HideColumn ? »
Или _GUICtrlListView_SetColumnWidth($hListView, 1, 0), это тоже самое.




© OSzone.net 2001-2012