Sign in to follow this  
Followers 0
Tipsy

Add an InsertMark in a listview with icons

6 posts in this topic

Hello,

i'm new to autoit and i love it. i was trying to change this code i found but i cannot make it work with "GUICtrlSetStyle($iLV, $LVS_ICON)". please advise.

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

Global $hGui, $iLV, $iMark, $Msg, $iIndex = 0
$hGui = GUICreate(":-)", 400, 300)
$iLV = GUICtrlCreateListView("Column 1", 5, 5, 300, 290)
GUICtrlSetStyle($iLV, $LVS_ICON)
_GUICtrlListView_SetExtendedListViewStyle($iLV, $LVS_EX_BORDERSELECT)
For $i = 0 To 9
    GUICtrlCreateListViewItem($i & ") Item", $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)
    $r = _SendMessage($hLV, $LVM_SETINSERTMARK, 0, DllStructGetPtr($tLVIMARK))
    ConsoleWrite($r&" "&DllStructGetPtr($tLVIMARK)&@CRLF)
EndFunc   ;==>_LV_InsertMark

Share this post


Link to post
Share on other sites



Tipsy,

Welcome to the AutoIt forum. :x

If I set the $LVS_ICON style as I create the ListView, everything seems to work as normal:

$iLV = GUICtrlCreateListView("Column 1", 5, 5, 300, 290, $LVS_ICON)
;GUICtrlSetStyle($iLV, $LVS_ICON)
_GUICtrlListView_SetExtendedListViewStyle($iLV, $LVS_EX_BORDERSELECT)

Does that solve your problem? :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Tipsy,

Welcome to the AutoIt forum. :x

If I set the $LVS_ICON style as I create the ListView, everything seems to work as normal:

$iLV = GUICtrlCreateListView("Column 1", 5, 5, 300, 290, $LVS_ICON)
;GUICtrlSetStyle($iLV, $LVS_ICON)
_GUICtrlListView_SetExtendedListViewStyle($iLV, $LVS_EX_BORDERSELECT)

Does that solve your problem? :P

M23

thanks but with that i won't be able to create a thumbnail type view. for some reason when you use the style after you create i'm getting the view i want.

thanks you very much for your help.

Share this post


Link to post
Share on other sites

Tipsy,

I see the problem now I have played with it a bit more. MSDN does say that the LVM_SETINSERTMARK message should work with icon view - but it does not seem to as you have discovered. A Windows or an AutoIt problem? Well beyond me to say, I am afraid. :x

Sorry I cannot be more helpful - I will try harder next time. :shifty:

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :P


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

these functions are undocumented in GuiListView.au3

_GUICtrlListView_SetInsertMark

_GUICtrlListView_SetInsertMarkColor

works with $LVS_AUTOARRANGE style

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

Global $hGui, $iLV, $iMark, $Msg, $iIndex = 0
$hGui = GUICreate(":-)", 400, 300)
$iLV = GUICtrlCreateListView("Column 1", 5, 5, 300, 290)
GUICtrlSetStyle($iLV, BitOR($LVS_AUTOARRANGE, $LVS_ICON))
_GUICtrlListView_SetExtendedListViewStyle($iLV, $LVS_EX_BORDERSELECT)
For $i = 0 To 9
    GUICtrlCreateListViewItem($i & ") Item", $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)
            _GUICtrlListView_SetInsertMark($iLV, $iIndex, False);insert before (False) or after (True) item
            $iIndex += 1
            _GUICtrlListView_SetInsertMarkColor($iLV, 0xFF0000)
    EndSwitch
WEnd

Func _LV_InsertMark($cListView, $iIndex)
    Local $tLVIMARK
    $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)
    $iRet = GUICtrlSendMsg($cListView, $LVM_SETINSERTMARK, 0, DllStructGetPtr($tLVIMARK))
    ;ConsoleWrite($iRet&" "&DllStructGetPtr($tLVIMARK)&@CRLF)
EndFunc   ;==>_LV_InsertMark

I see fascists...

Share this post


Link to post
Share on other sites

rover,

I just knew someone clever would come along with the answer - might have guessed it would be you! :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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