Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Urs Eggmann" Newsgroups: comp.lang.clipper.visual-objects Subject: Re: Most efficient way to re-arrange bBrowser columns? Date: Fri, 28 Dec 2012 22:02:53 +0100 Lines: 131 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 8bit X-Trace: individual.net LGuvZ/1PfFiA119By8d2GQ8yYnfzNMKo+CJauFkTgY/mZt5FrVACyUpWpPMTkAki6v Cancel-Lock: sha1:4z67CXcXPz4GTgR5X6EZJkfxutY= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-EsetId: 35EFE320EBB639326FAAB8 X-EsetScannerBuild: 12802 Xref: csiph.com comp.lang.clipper.visual-objects:4527 Hi Dick, In the method QueryClose() of my window I call SaveColumnConfig() and write the two arrays [SELF:Owner:Schreiben( {asFields , anFields } ] into a file. For that I use Joachims bStream Class. In the Init (or PostInit) I call a method BrowserConfig() where I reconstruct the Colum pos and Width. This method takes between 15 and 20 msec!! If you need more precise info, let me know, I could prepare a working sample. Regards Urs Used code: METHOD SaveColumnConfig() CLASS dtaTabelle // Speicherung der Spaltenordnung und Grösse LOCAL aColumns , asFields , anFields AS ARRAY LOCAL nZaehler AS DWORD IF SELF:oCCrbBenutzer:pressed // Für die Benutzer definierte Spaltenordnung aColumns := SELF:oDCbBrowser1:ColumnOpenList // Offene Spalten auslesen asFields := {} // Array für Feldnamen anFields := {} // Array für Spaltenbreite FOR nZaehler = 1 TO ALen( aColumns ) AAdd( asFields , aColumns[nZaehler]:NameSym ) // Array mit Symbol füllen AAdd( anFields , aColumns[nZaehler]:Width ) // Array mit Spaltenbreite füllen NEXT nZaehler SELF:Owner:Schreiben( {asFields , anFields } , "CD-SpaltenPosition.cfg" ) // Felderdaten in File schreiben ENDIF METHOD Schreiben(uValue,cFile) CLASS AppShell LOCAL oStream AS bStream LOCAL hFile AS PTR oStream := bStream{} oStream:Write(uValue) IF oStream:Write(uValue) // Binär-String in Datei speichern hFile := FCreate(cFile) FWrite(hFile, oStream:Stream, oStream:Size) FClose(hFile) ENDIF RETURN cFile METHOD Lesen(cFile) CLASS AppShell // Get the two arrays back LOCAL uValue AS USUAL LOCAL oStream AS bStream LOCAL cStream AS STRING LOCAL iSize AS INT LOCAL hFile AS PTR IF File(cFile) // Binär-String aus der Datei auslesen hFile := FOpen(cFile) iSize := FSeek(hFile, 0, FS_END) FSeek(hFile, 0, FS_SET) cStream := FReadStr(hFile, iSize) FClose(hFile) // Binär-String zurück konvertieren oStream := bStream{cStream} uValue := oStream:Read() ENDIF // ShowArray(uValue) RETURN uValue ********************** snip ******************** // in PostInit... CASE sControlName == #rbBenutzer aFieldInfo := SELF:Owner:Lesen("CD-SpaltenPosition.cfg") // Feldinfo aus File lesen asFields := aFieldInfo[1] // Feldnamen holen anFields := aFieldInfo[2] // Spaltenbreite holen nLen := ALen(anFields) FOR nZaehler := 1 TO nLen oColumn := SELF:oDCbBrowser1:GetColumn(asFields[nZaehler]) oColumn:Width := anFields[nZaehler] * nBreite += anFields[nZaehler] oColumn:Caption := " " + oColumn:Caption oColumn:CaptionView := bViewStyle{ , ,BALIGN_LEFT+BALIGN_VCENTER} SELF:oDCbBrowser1:AddColumn( oColumn) SELF:oDCbBrowser1:OpenColumn(oColumn) NEXT nZaehler ********************** snip ******************** "D.J.W. van Kooten" schrieb im Newsbeitrag news:f60rd8dcb4r6ts9mp2eiaj394v5ohpr88b@4ax.com... > We store user settings of bBrowser column positions and width. After > initializing the bBrowser with the programmed defaults, the code below > re-arranges the bBrowser by resizing to the size stored in aCols (read > from the setting file) and then move the columns in the order as > stored in this array. I found that especially the Move is quite time > consuming; it can take 3 seconds. > > Can anyone recommend a quicker way to re-arrange the columns in a > different order? > > > FOR dwIndex := 1 UPTO ALen (aCols) > cField := aCols [dwIndex, 1] > dwSize := aCols [dwIndex, 3] > dwColpos := oBrowser:GetOpenColumnNo (cField) > oBrowser:ResizeColumn (dwColpos, dwSize) > oBrowser:MoveColumn (dwColpos, 0) // move column behind last > column > NEXT > > > Dick