Re: [Win32lib] Listview speed
Ooops, I forgot to address the other issue you raised - how to use the
built-in sorting of the library.
I've adjusted the demo example to so how to do that.
---------------------
object VOID
include win32lib.ew
include sort.e
without warning
constant w = createEx(Window,"test load", 0, 0, 0, 400, 0400, 0, 0),
lv = createEx(ListView, {"English","Digit", "Thai"}, w, 10, 10,
300, 300, LVS_REPORT , 0)
global procedure loadLVInfo(atom id, sequence alldata)
atom hWnd
atom LV_ITEM
sequence data
integer msg
hWnd = getHandle(id)
VOID = w32Func( xSendMessage, {hWnd, LVM_DELETEALLITEMS, 0, 0})
LV_ITEM = acquire_mem(0, SIZEOF_LVITEM )
for i = 1 to length(alldata) do
store( LV_ITEM, LVITEM_iItem, i-1)
store( LV_ITEM, LVITEM_lParam, i )
data = alldata[i]
for j = 1 to length(data) do
store( LV_ITEM, LVITEM_iSubItem, j-1 )
store( LV_ITEM, LVITEM_pszText, data[j] )
store( LV_ITEM, LVITEM_cchTextMax, length(data[j]) )
if j = 1 then
msg = LVM_INSERTITEM
store( LV_ITEM, LVITEM_mask,
or_all({LVIF_TEXT,LVIF_PARAM}) )
else
msg = LVM_SETITEM
store( LV_ITEM, LVITEM_mask, LVIF_TEXT )
end if
VOID = w32Func( xSendMessage, { hWnd, msg, j-1, LV_ITEM } )
end for
end for
release_mem(LV_ITEM)
end procedure
sequence theData theData = {}
theData = append(theData, {"One", "1", "neung"})
theData = append(theData, {"Two", "2", "song"})
theData = append(theData, {"Three", "3", "sam"})
theData = append(theData, {"Four", "4", "si"})
theData = append(theData, {"Five", "5", "ha"})
theData = append(theData, {"Six", "6", "hok"})
theData = append(theData, {"Seven", "7", "jet"})
theData = append(theData, {"Eight", "8", "baht"})
theData = append(theData, {"Nine", "9", "kow"})
theData = append(theData, {"Ten", "10", "sip"})
loadLVInfo(lv, theData)
-- Set the attributes to use the built-in sorting.
VOID = setLVAttr( lv, {{kLVColTypes, {'i','n','i'}},
{kLVSortSeq, {1, 1, 1}}
})
WinMain(w, Normal)
---------------------
Derek
----- Original Message -----
From: <euman at bellsouth.net>
To: "EUforum" <EUforum at topica.com>
Sent: Saturday, June 15, 2002 9:23 AM
Subject: [Win32lib] Listview speed
>
> Hello Matt Lewis and all,
>
> The (below) procedure is faster for loading Items into a listview
> however, I havent figured out how I plan to sort the data using this
> routine. I'll work on this some more tonight.
>
> You also can not sort the listview using the current Win32lib sort
> algorythm and this procedure, perhaps someone who knows the lib
> better would do this.
>
> If your plans are to not allow sorting then this will be a better choice
> for speed.
>
> -- add to Win32lib
> global procedure LoadLVInfo(atom id, sequence alldata)
> integer howmany
> handle = getHandle(id)
> howmany = length(alldata)
> for i = 1 to howmany do
> LV_ITEM = acquire_mem(0, SIZEOF_LVITEM )
> store( LV_ITEM, LVITEM_mask, LVIF_TEXT )
> store( LV_ITEM, LVITEM_iItem, i-1)
> data = alldata(i)
> subitem = 0
> for x = 1 to length(data) do
> store( LV_ITEM, LVITEM_iSubItem, subitem )
> store( LV_ITEM, LVITEM_pszText, data[x] )
> store( LV_ITEM, LVITEM_cchTextMax, length(data[x]) )
> subitem += 1
> if subitem = 1 then
> junk = w32Func( xSendMessage, { handle, LVM_INSERTITEM, 0,
LV_ITEM } )
> else
> junk = w32Func( xSendMessage, { handle, LVM_SETITEM, i-1,
LV_ITEM } )
> end if
> end for
> store( LV_ITEM, LVITEM_lParam, i )
> release_mem(LV_ITEM)
> end for
> end procedure
>
> P.S this routine would be faster if hacked.
> e.g straight pokes( ) instead of store( ) and/or, inlining the routine in
your program.
>
> Good Day!
>
> Euman
> euman at bellsouth.net
>
> ==================================================================
> 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.
> ==================================================================
>
>
>
>
|
Not Categorized, Please Help
|
|