Jump to content

Create an insertmark in a listview


Markus
 Share

Recommended Posts

Hi,

I want to create an insertmark using this code:

;create the structure
$a = DllStructCreate("uint cbSize;dword dwFlags;int iItem;dword dwReserved")
;DllStructSetData($a,"cbSize",-1)
DllStructSetData($a,"dwFlags","LVIM_AFTER")
DllStructSetData($a,"iItem",1)
DllStructSetData($a,"dwReserved",0)

;send the message
_SendMessage(GUICtrlGetHandle($mylistview), $LVM_SETINSERTMARK, 0, DllStructGetPtr($a))

MSDN Source for SendMessage

MSDN Source for the DLLStruct

It just doesn't work. Please help me.

Greets

Markus

EDIT: DllStructSetData($a,"cbSize",DllStructGetSize($a)) is the solution

Edited by Markus

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Link to comment
Share on other sites

Hi,

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <SendMessage.au3>

Global $hGui, $iLV, $iMark, $Msg, $iIndex = 0
$hGui = GUICreate(":-)", 400, 300)
$iLV = GUICtrlCreateListView("Column 1|Column 2", 5, 5, 300, 290)
For $i = 0 To 9
    GUICtrlCreateListViewItem($i & ") Item|Subitem", $iLV)
Next
$iMark = GUICtrlCreateButton("Set Mark", 310, 120, 85, 25)
GUISetState(@SW_SHOW, $hGui)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iMark
            If $iIndex = _GUICtrlListView_GetItemCount($iLV) Then $iIndex = 0
            _LV_InsertMark($iLV, $iIndex)
            $iIndex += 1
    EndSwitch
WEnd

Func _LV_InsertMark($hListView, $iIndex)
    Local $tLVIMARK, $hLV
    $tLVIMARK = DllStructCreate("uint cbSize;dword dwFlags;int iItem;dword dwReserved")
    DllStructSetData($tLVIMARK, "cbSize", DllStructGetSize($tLVIMARK))
    DllStructSetData($tLVIMARK, "dwFlags", $LVIM_AFTER)
    DllStructSetData($tLVIMARK, "iItem", $iIndex)
    DllStructSetData($tLVIMARK, "dwReserved", 0)
    $hLV = $hListView
    If Not IsHWnd($hLV) Then $hLV = GUICtrlGetHandle($hListView)
    _SendMessage($hLV, $LVM_SETINSERTMARK, 0, DllStructGetPtr($tLVIMARK))
EndFunc   ;==>_LV_InsertMark

Cheers

Edited by smashly
Link to comment
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
 Share

  • Recently Browsing   0 members

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