Sign in to follow this  
Followers 0
Info

Change the position of an item in a ListView control with $LVS_LIST, $LVS_ICON styles

5 posts in this topic

#include <GUIListView.au3>
#include <GUIImageList.au3>

$hGUI = GUICreate("")
$hGUIListView = _GUICtrlListView_Create($hGUI,"", 0, 0, 212, 300, BitOR($LVS_LIST, $LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
$hImageList = _GUIImageList_Create(24,24, 5)
_GUIImageList_AddIcon($hImageList, "icon.ico",0,True)
_GUICtrlListView_SetImageList($hGUIListView, $hImageList, 1)

_GUICtrlListView_AddItem($hGUIListView, "1", 0)
_GUICtrlListView_AddItem($hGUIListView, "2", 0)
_GUICtrlListView_AddItem($hGUIListView, "3", 0)
GUISetState()

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

I've tried using _GUICtrlListView_SetItemPosition() but it doesn't seem to work, maybe because the ListView has the $LVS_LIST style.

Share this post


Link to post
Share on other sites



I've tried using _GUICtrlListView_SetItemPosition() but it doesn't seem to work, maybe because the ListView has the $LVS_LIST style.

Correct, AutoIt help says "The control must be in icon or small icon view mode". This works for me

#include <GUIListView.au3>
#include <GUIImageList.au3>

$hGUI = GUICreate("")
$hGUIListView = _GUICtrlListView_Create($hGUI, "", 0, 0, 212, 300, BitOR($LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SMALLICON));$LVS_LIST))
$hImageList = _GUIImageList_Create(24, 24, 5)
_GUIImageList_AddIcon($hImageList, @ProgramFilesDir & "\AutoIt3\Icons\au3script_v9.ico", 0, True)
_GUICtrlListView_SetImageList($hGUIListView, $hImageList, 1)

_GUICtrlListView_AddItem($hGUIListView, "1", 0)
_GUICtrlListView_AddItem($hGUIListView, "2", 0)
_GUICtrlListView_AddItem($hGUIListView, "3", 0)
GUISetState()

_GUICtrlListView_SetItemPosition($hGUIListView, 0, 25, 80)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Share this post


Link to post
Share on other sites

I need the $LVS_LIST style in my listview :blink:

Share this post


Link to post
Share on other sites

Is this any good ?

#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>

$hGUI = GUICreate("")
$hGUIListView = _GUICtrlListView_Create($hGUI, "", 0, 0, 212, 300, BitOR($LVS_LIST, $LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
$hImageList = _GUIImageList_Create(24, 24, 5)
_GUIImageList_AddIcon($hImageList, "icon.ico", 0, True)
_GUICtrlListView_SetImageList($hGUIListView, $hImageList, 1)

_GUICtrlListView_AddItem($hGUIListView, "1", 0)
_GUICtrlListView_AddItem($hGUIListView, "2", 0)
_GUICtrlListView_AddItem($hGUIListView, "3", 0)
GUISetState()

MsgBox(0, "", "moving index 2 to index 0 position")
_guiCtrlListViewMoveIndex($hGUIListView, 2, 0)
MsgBox(0, "", "moving index 1 to index 2 position")
_guiCtrlListViewMoveIndex($hGUIListView, 1, 2)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func _guiCtrlListViewMoveIndex($hWnd, $iCurrentIndex, $iNewIndex)
    $sText = _GUICtrlListView_GetItemText($hWnd, $iCurrentIndex)
    _GUICtrlListView_DeleteItem($hWnd, $iCurrentIndex)
    _GUICtrlListView_InsertItem($hWnd, $sText, $iNewIndex)
EndFunc   ;==>_guiCtrlListViewMoveIndex

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

yes

thanks!

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