Jump to content

The new GuiCtrlCreateListView


Antiec
 Share

Recommended Posts

Hi!

How come the old GuiCtrlCreateListView created an incorrect listview "Fixed: Incorrect listview creation with GUICtrlCreateListView() (3.2.8.0)". It worked just like I wanted it to and now I'm unable to get it working anymore. I noticed that sorting by the column names won't work anymore (at the help)... Is there any other way to make it work in the same way as before than to change back to 3.2.6.0?

I'm using following code (yeah, it really isn't effective) and atleast I'd like to make it show the info I like it to...

CODE
$ListView = GUICtrlCreateListView( " ", 8, 25, 535, 200, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING) ) ; Seems to work

GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)

_GUICtrlListViewInsertColumn ( $ListView, 0, "height", 0, 195 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "width", 0, 195 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Frames", 0, 195 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "File name", 0, 150 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Time", 0, 50 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Date", 0, 50 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Name", 0, 195 )

_GUICtrlListViewJustifyColumn ( $ListView, 1, 2 )

_GUICtrlListViewJustifyColumn ( $ListView, 2, 2 )

_GUICtrlListViewEnsureVisible ( $ListView, 0, True )

GUICtrlCreateListViewItem("Test|2007/11/13|13:40|test.txt|50|200|300", $ListView) <------------- Returns 0

GUICtrlCreateListViewItem( "1|2|3|4|5|6|7", $ListView )

_GUICtrlListViewSetItemSelState ( $ListView, 0, 1 )

_GUICtrlListViewHideColumn ( $ListView, 4 )

_GUICtrlListViewHideColumn ( $ListView, 5 )

_GUICtrlListViewHideColumn ( $ListView, 6 )

_GUICtrlListViewHideColumn ( $ListView, 7 )

Link to comment
Share on other sites

Hi!

How come the old GuiCtrlCreateListView created an incorrect listview "Fixed: Incorrect listview creation with GUICtrlCreateListView() (3.2.8.0)". It worked just like I wanted it to and now I'm unable to get it working anymore. I noticed that sorting by the column names won't work anymore (at the help)... Is there any other way to make it work in the same way as before than to change back to 3.2.6.0?

I'm using following code (yeah, it really isn't effective) and atleast I'd like to make it show the info I like it to...

CODE
$ListView = GUICtrlCreateListView( " ", 8, 25, 535, 200, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING) ) ; Seems to work

GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)

_GUICtrlListViewInsertColumn ( $ListView, 0, "height", 0, 195 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "width", 0, 195 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Frames", 0, 195 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "File name", 0, 150 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Time", 0, 50 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Date", 0, 50 )

_GUICtrlListViewInsertColumn ( $ListView, 0, "Name", 0, 195 )

_GUICtrlListViewJustifyColumn ( $ListView, 1, 2 )

_GUICtrlListViewJustifyColumn ( $ListView, 2, 2 )

_GUICtrlListViewEnsureVisible ( $ListView, 0, True )

GUICtrlCreateListViewItem("Test|2007/11/13|13:40|test.txt|50|200|300", $ListView) <------------- Returns 0

GUICtrlCreateListViewItem( "1|2|3|4|5|6|7", $ListView )

_GUICtrlListViewSetItemSelState ( $ListView, 0, 1 )

_GUICtrlListViewHideColumn ( $ListView, 4 )

_GUICtrlListViewHideColumn ( $ListView, 5 )

_GUICtrlListViewHideColumn ( $ListView, 6 )

_GUICtrlListViewHideColumn ( $ListView, 7 )

Something similar happened to me on one of my scripts yesterday. In my code I was creating the listview control without any columns, and then adding columns using _GUICtrlListviewInsertColumn. Apparently the new changes to made to listview have made it incompatible with _GUICtrlListviewInsertColumn as the only way I can get columns added to my listview control is to specify them up front like this

$ListView = GUICtrlCreateListView( "Col1|Col2|Col3|Col4 ", 8, 25, 535, 200, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING) )

vs adding them on the fly with _GUICtrlListviewInsertColumn.

Anyone else having this problem?

Thanks,

John

Link to comment
Share on other sites

To me this would be a bug... Should be able to add/remove columns on the fly, not just specify them when creating the control

this works for now, but like I said I would consider this a bug, otherwise why would windows have api calls to insert/delete columns.

#include <GUIConstants.au3>
#include <GuiListView.au3>

GUICreate("listview items",500,500)
GUISetBkColor (0x00E0FFFF)  ; will change background color

;~ $ListView = GUICtrlCreateListView( " ", 8, 25, 535, 200, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING) ) ; Seems to work
$ListView = GUICtrlCreateListView( "Name|Date|Time|File name|Frames|width|height", 8, 25, 535, 200, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING) ) ; Seems to work
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
;~ _GUICtrlListViewDeleteColumn($ListView, 0)
_GUICtrlListViewSetColumnWidth($ListView, 0, 195)
_GUICtrlListViewSetColumnWidth($ListView, 1, 50)
_GUICtrlListViewSetColumnWidth($ListView, 2, 50)
_GUICtrlListViewSetColumnWidth($ListView, 3, 150)
_GUICtrlListViewSetColumnWidth($ListView, 4, 195)
_GUICtrlListViewSetColumnWidth($ListView, 5, 195)
_GUICtrlListViewSetColumnWidth($ListView, 6, 195)
;~ _GUICtrlListViewInsertColumn ( $ListView, 0, "height", 0, 195 )
;~ _GUICtrlListViewInsertColumn ( $ListView, 0, "width", 0, 195 )
;~ _GUICtrlListViewInsertColumn ( $ListView, 0, "Frames", 0, 195 )
;~ _GUICtrlListViewInsertColumn ( $ListView, 0, "File name", 0, 150 )
;~ _GUICtrlListViewInsertColumn ( $ListView, 0, "Time", 0, 50 )
;~ _GUICtrlListViewInsertColumn ( $ListView, 0, "Date", 0, 50 )
;~ _GUICtrlListViewInsertColumn ( $ListView, 0, "Name", 0, 195 )
_GUICtrlListViewJustifyColumn ( $ListView, 1, 2 )
_GUICtrlListViewJustifyColumn ( $ListView, 2, 2 )
_GUICtrlListViewEnsureVisible ( $ListView, 0, True )

GUICtrlCreateListViewItem("Test|2007/11/13|13:40|test.txt|50|200|300", $ListView)

GUICtrlCreateListViewItem( "1|2|3|4|5|6|7", $ListView )
_GUICtrlListViewSetItemSelState ( $ListView, 0, 1 )
_GUICtrlListViewHideColumn ( $ListView, 4 )
_GUICtrlListViewHideColumn ( $ListView, 5 )
_GUICtrlListViewHideColumn ( $ListView, 6 )
;~ _GUICtrlListViewHideColumn ( $ListView, 7 )

GUISetState()

Do
  $msg = GUIGetMsg ()
Until $msg = $GUI_EVENT_CLOSE

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Actually you can use GUICtrlCreateListView() and _GUICtrlListViewInsertColumn() in the same way as before. You just have to use $ListView = GUICtrlCreateListView( " ", 8, 25, 535, 200, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING) ) <---- See, there's " " (a space between). You can't create an empty listview and this will create one nameless column.

And I played around a bit with the example code from the help. I kinda can't remake any problems with it. It just works. Now I'd like to know why my old script doesn't work anymore. Everything else is ok, but "GUICtrlCreateListViewItem("Test|2007/11/13|13:40|test.txt|50|200|300", $ListView)" Returns 0

And my bad... You couldn't use that explorer column sorting even before. I had the following code in my message procedure.

CODE
Case $msg = $Listview

_GUICtrlListViewSort($Listview, $B_DESCENDING, GUICtrlGetState($PatientList))

PS. How do you make a smaller codebox? And some tabs or spaces before a line?

Link to comment
Share on other sites

Actually, after a bit more playing around... I found out that _GUICtrlListViewInsertColumn() adds a column but it doesn't count as one. So it does add one so you can see it but you can't add data into it.

In other words if "GUICtrlCreateListViewItem( "1|2|3|4|5|6|7", $ListView )" (has 7 columns) returns 0 if you use it for a listview which has only 6 colums. And _GUICtrlListViewInsertColumn() doesn't add a new column from the codes point of view, so GUICtrlCreateListViewItem() will fail. Gosh I'm bad in explaining things :) (And my english isn't too good either).

And it most certainly is a bug.

Edit: Thx to gafrost for pointing out a workaround.

Edited by Antiec
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...