RE: Faster addLVItem's
- Posted by Derek Parnell <Derek.Parnell at SYD.RABOBANK.COM> Jul 24, 2002
- 372 views
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_01C23303.54E88C00 charset=iso-8859-1 > -----Original Message----- > From: Tony Steward [mailto:tony at locksdownunder.com] > Subject: RE: Faster addLVItem's > > > > Hi All, > A lot of talk about virtual listviews. > Could someone knock up an example of how we can use the VLV. > ------------------------------------------------ -- Viewer.exw Version: 1.0 -- -- This is one technique that can be used to view a large number of records. ------------------------------------------------ without warning include win32lib.ew object VOID ------------------------------------------------ -- Controls IDs ------------------------------------------------ integer MainWin, SB, Viewer sequence vData vData = {} integer vMaxData vMaxData = 35000 procedure buildDummyData(integer pCount) sequence lDate sequence lAmount sequence lChqNo sequence lStatus sequence lBank for i = 1 to pCount do lDate = sprintf("2001 %02d %02d", {rand(12), rand(28)}) lAmount = sprintf("%9.2f", rand(999999)/100) lChqNo = sprintf("%6d", rand(999999)) lStatus = iff(rand(10) < 3, "R", " ") lBank = sprintf("%5d", rand(9999)+10000) vData = append(vData, {lChqNo, lDate, lAmount, lStatus, lBank}) end for end procedure function getdispinfo(integer id, atom hWnd, atom wParam, atom lParam) atom lMask integer lColumn, lRow sequence lData id = getId( fetch( lParam, NMHDR_hwndFrom )) if id != 0 then lMask = fetch( lParam, LVDISPINFO_LVITEMmask ) lColumn = fetch( lParam, LVDISPINFO_LVITEMiSubItem ) + 1 lRow = fetch( lParam, LVDISPINFO_LVITEMiItem ) + 1 if and_bits(lMask, LVIF_TEXT) then if lRow <= vMaxData then if lRow > length(vData) then setText(SB, sprintf("%3.2f%% loaded", (100 * length(vData) )/ vMaxData)) buildDummyData( lRow - length(vData)) end if lData = vData[lRow][lColumn] store(lParam, LVDISPINFO_LVITEMpszText, lData) store(lParam, LVDISPINFO_LVITEMcchTextMax, length(lData)) else store(lParam, LVDISPINFO_LVITEMpszText, -1) store(lParam, LVDISPINFO_LVITEMcchTextMax, -1) end if end if end if return kReturnNow end function ------------------------------------------------ procedure Activate_MainWin(integer self, integer event, sequence parms) ------------------------------------------------ VOID = sendMessage( Viewer, LVM_SETITEMCOUNT, vMaxData, 0) VOID = setNotifyHandler(LVN_GETDISPINFO, routine_id("getdispinfo")) end procedure ------------------------------------------------ -- Application Initiation ------------------------------------------------ function AppInit() integer lRC lRC = 0 MainWin = createEx(Window, "", 0, 0, 0, 600, 400, 0, 0) SB = createEx( StatusBar, "", MainWin, 0,0,0,0, 0, 0) Viewer = createEx( ListView, {"Chq#","Date","Amount","Status","Bank"}, MainWin, 10,20,540, 310, or_all({LVS_REPORT ,LVS_OWNERDATA }) , 0) VOID = sendMessage(Viewer, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, or_all({LVS_EX_FULLROWSELECT,LVS_EX_HEADERDRAGDROP})) -- Link in the event handlers. setHandler(MainWin, w32HActivate, routine_id("Activate_MainWin")) return lRC end function if AppInit() = 0 then WinMain( MainWin, Normal) end if ------------------------- > Also Virtual or not, is there a way a user can move the > columns in a LV. See the example above, but it is done thru setting an extended listview style... Here is the code to set JUST that style and no others... VOID = sendMessage(Viewer, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_HEADERDRAGDROP,LVS_EX_HEADERDRAGDROP) ----------- 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_01C23303.54E88C00 Content-Type: application/ms-tnef