Jump to content

Select and unselect an item of listview WITH $LVS_NOCOLUMNHEADER ? [SOLVED]


Jikoo
 Share

Recommended Posts

Hello,

Is it possible to select and unselect an item of listview with $LVS_NOCOLUMNHEADER ?... because without it, it works !

Thank you

I use the AutoIt version : 3.2.12.1

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

$gui = GUICreate('Test ListView select-unselect', 300, 200)
$glList = GUICtrlCreateListView('Column         ', 0, 0, 300, 160, $LVS_NOCOLUMNHEADER)
$b1 = GUICtrlCreateButton('Select', 20, 170)
$b2 = GUICtrlCreateButton('Unselect', 70, 170)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, "shell32.dll", 3)
_GUIImageList_AddIcon($hImage, "shell32.dll", 1)
_GUIImageList_AddIcon($hImage, "shell32.dll", 11)
_GUICtrlListView_SetImageList($glList, $hImage, 1)

_GUICtrlListView_AddItem($glList, "Item0", 0)
_GUICtrlListView_AddItem($glList, "Item1", 1)
_GUICtrlListView_AddItem($glList, "Item2", 2)

GUISetState()

While 1
    Sleep(10)
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $b1
            _GUICtrlListView_SetItemSelected($glList, 1, True)
        Case $b2
            _GUICtrlListView_SetItemSelected($glList, 1, False)
    EndSwitch
WEnd
Edited by Jikoo
My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).
Link to comment
Share on other sites

Jikoo

Use a $LVS_SHOWSELALWAYS style:

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

$gui = GUICreate('Test ListView select-unselect', 300, 200)
$glList = GUICtrlCreateListView('Column         ', 0, 0, 300, 160, BitOR($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER))
$b1 = GUICtrlCreateButton('Select', 20, 170)
$b2 = GUICtrlCreateButton('Unselect', 70, 170)

$hImage = _GUIImageList_Create(16, 16, 5, 3)

_GUIImageList_AddIcon($hImage, "shell32.dll", 3)
_GUIImageList_AddIcon($hImage, "shell32.dll", 1)
_GUIImageList_AddIcon($hImage, "shell32.dll", 11)
_GUICtrlListView_SetImageList($glList, $hImage, 1)

_GUICtrlListView_AddItem($glList, "Item0", 0)
_GUICtrlListView_AddItem($glList, "Item1", 1)
_GUICtrlListView_AddItem($glList, "Item2", 2)

GUISetState()

While 1
    Sleep(10)
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $b1
            _GUICtrlListView_SetItemSelected($glList, 1, True, True)
        Case $b2
            _GUICtrlListView_SetItemSelected($glList, 1, False)
    EndSwitch
WEnd
Link to comment
Share on other sites

One more time, thank you very much rasim,

You are everywhere ! :(:P

My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).
Link to comment
Share on other sites

rasim is right but I will add more detailed GENERAL explanation here:

ListView (and also other controls) has some default styles even if you don't explicitly define them in GUICtrlCreate...

When you wan't to add some new style (to combine styles with the default style) you should use:

BitOr($GUI_SS_DEFAULT_LISTVIEW, newstyle,...)

here in your case:

$glList = GUICtrlCreateListView('Column      ', 0, 0, 300, 160,  BitOr($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER))

if you use only your new style then all default styles are not used ("are destroyed"):

$glList = GUICtrlCreateListView('Column      ', 0, 0, 300, 160, $LVS_NOCOLUMNHEADER)
Link to comment
Share on other sites

Thank you Zedna for your explanation. It's clear. :P

My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).
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...