RE: win32lib listview suggestions

new topic     » topic index » view thread      » older message » newer message

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C2311D.BAD81090
 charset=iso-8859-1


> -----Original Message-----
> From: 10963508 at europeonline.com [mailto:10963508 at europeonline.com]
> Subject: Re: win32lib listview suggestions
> 
> 
> 
> ----- Original Message -----
> From: "Derek Parnell" <ddparnell at bigpond.com>
> 
> > > - Natural sort, 1,3,20 and not 1,20,3
> >
> > This is already catered for. You can tell win32lib, which 
> columns contain
> > numbers and thus it sorts the column correctly.
> 
> I use it now, but it's slow beyond being usable.
> I know this discussion went on before but what do I need to 
> do to speed it
> up?
> I have about 60 items in listview and it takes about 3 
> seconds to sort those
> numbers. This needs to be fixed in Win32Lib in my opinion, it 
> should be fast
> by default.

The ListView control stores data as text, not as numbers. So, if you want to
do numeric comparisions, then you must either convert them to back to
numbers first, or compare a shadow copy of the listview column data, stored
as numbers, that you are managing yourself.

Another approach is to add the numeric items as RIGHT-ALIGNED text with
leading spaces. Then a simple text comparision will be sufficient. Also, if
you replace the generic comparision routine with your own, you may find some
improvement too. For example...

  procedure mysort(integer id, atom a, atom b, integer col)
	return compare(getLVItemText(id, a, col), getLVItemText(id, b, col))
  end procedure
  x = routine_id("mysort")
  ov = setLVAttr( LV, {{kLVSortRtn, {x,x,x}}})
  -- Add items...
  AddItem(LV, 0, {"Derek Parnell", sprintf("%4d", age), sprintf("%3.2f,
weight)})


> One more problem:
> after I inserted items into listview they are not sorted. 
> What function do I
> need to call to sort items of specified column, not first but 
> some other
> column?
> like in windows file explorer, you click on column header and 
> then that
> column is sorted that way when you click on different folders.

I don't have access to the API documentation just now, so I can't check this
out. I don't remember anything though. I supose you could simulate a mouse
button click on the column header. Or maybe you have to load the LV in the
initial order first.

-----------
Derek.

==================================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en 
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht 
onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en 
de afzender direct te informeren door het bericht te retourneren. 
==================================================================
The information contained in this message may be confidential 
and is intended to be exclusively for the addressee. Should you 
receive this message unintentionally, please do not use the contents 
herein and notify the sender immediately by return e-mail.


==================================================================

------_=_NextPart_000_01C2311D.BAD81090
Content-Type: application/ms-tnef

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu