Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #4524 > unrolled thread
| Started by | D.J.W. van Kooten <public@ic2remove.this.com> |
|---|---|
| First post | 2012-12-28 12:26 +0100 |
| Last post | 2013-01-08 09:05 +0100 |
| Articles | 8 — 5 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Most efficient way to re-arrange bBrowser columns? D.J.W. van Kooten <public@ic2remove.this.com> - 2012-12-28 12:26 +0100
Re: Most efficient way to re-arrange bBrowser columns? wd <WD@delius-consult.de> - 2012-12-28 03:38 -0800
Re: Most efficient way to re-arrange bBrowser columns? "Er!k \\/!$$Er" <nospam@nospam.url> - 2012-12-28 20:01 +0100
Re: Most efficient way to re-arrange bBrowser columns? "Urs Eggmann" <Urs.Eggmann@shinternet.ch> - 2012-12-28 22:02 +0100
Re: Most efficient way to re-arrange bBrowser columns? D.J.W. van Kooten <public@ic2remove.this.com> - 2012-12-31 15:28 +0100
Re: Most efficient way to re-arrange bBrowser columns? Mathias <mathias.hakansson@consultec.se> - 2013-01-07 22:38 -0800
Re: Most efficient way to re-arrange bBrowser columns? Mathias <mathias.hakansson@consultec.se> - 2013-01-07 22:55 -0800
Re: Most efficient way to re-arrange bBrowser columns? D.J.W. van Kooten <public@ic2remove.this.com> - 2013-01-08 09:05 +0100
| From | D.J.W. van Kooten <public@ic2remove.this.com> |
|---|---|
| Date | 2012-12-28 12:26 +0100 |
| Subject | Most efficient way to re-arrange bBrowser columns? |
| Message-ID | <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
[toc] | [next] | [standalone]
| From | wd <WD@delius-consult.de> |
|---|---|
| Date | 2012-12-28 03:38 -0800 |
| Message-ID | <e3c906b4-3bb6-4bd2-96b9-d2a204d79be1@googlegroups.com> |
| In reply to | #4524 |
Hi Dick,
I can show a more complicated way:
the standard bBrowser stores the actual arrangement when closing and restores when opening again.
METHOD restoreColumnWidth() CLASS stdBBrowser
// Stellt die Spaltenbreiten wieder her
LOCAL nWidth as DWORD
LOCAL n, nLen as DWORD
LOCAL cName as STRING
LOCAL symName as SYMBOL
LOCAL cHelp as STRING
LOCAL aOpen as ARRAY
LOCAL acFields as ARRAY
LOCAL oIni as IniFile
LOCAL oCol as bDataColumn
LOCAL cIni as String
cIni := self:Server:filespec:fullpath
cIni := SubStr(cIni,1,At( ".",cIni)-1) + ".BBR"
oIni := IniFile{cIni}
// Spaltenreihenfolge einlesen
acFields := str2arr(oIni:GetString(self:cSection, "FelderReihenfolge"))
IF alen(acFields) > 1 // Felderarray aus File lesen
SELF:clear(TRUE) // alle Spalten löschen
SELF:OpenColumn(acFields) // und neu öffnen
ENDIF
nLen := ALen(self:aoColumn) // SELF:ColumnOpenCount
aOpen := {}
FOR n:= 1 upto nLen
// Hole die Spalte ein ...
oCol := self:aoColumn[n]
IF oCol != null_object
// ... ermittle Name ...
cName := oCol:Caption
symName := oCol:HyperLabel:NameSym
// ... prüfe, ob es einen Eintrag dafür in der INI-Datei gibt ...
cHelp := oIni:GetString(self:cSection, cName)
IF !Empty(cHelp)
nWidth := Val(Token(cHelp,1,";"))
oCol:Width := nWidth
ENDIF
ENDIF
oCol:Caption := cName := SubStr(cName,1,1) + Lower(SubStr(cName,2))
if instr("_",cName)
//Transform(
oCol:Caption := strTran(cName,substr(cName,At("_",cName)+1,1),;
Upper(substr(cName,At("_",cName)+1,1)),,1 )
endif
NEXT
METHOD SaveColumnWidth() CLASS stdBBrowser
// Speichert die Spaltenbreiten
LOCAL n, nLen as DWORD
// LOCAL nPos as DWORD
LOCAL cWidth as STRING
LOCAL cName as STRING
LOCAL cFields as STRING
LOCAL aCol as ARRAY
LOCAL acFields as ARRAY
LOCAL oIni as IniFile
LOCAL oColumn as bDataColumn
LOCAL cIni as String
cIni := self:Server:filespec:fullpath
cIni := SubStr(cIni,1,At( ".",cIni)-1) + ".BBR"
oIni := IniFile{cIni}
aCol := self:ColumnOpenList
nLen := ALen(aCol) // SELF:ColumnCount
acFields := {} // Array für Feldnamen
FOR n:= 1 upto nLen
// Hole die Spalte ein ...
oColumn := aCol[n]
IF oColumn != null_object
// ... ermittle Name/Breite ...
cName := oColumn:Caption
cWidth := AsString(oColumn:Width)
AAdd( acFields , cName) // Array mit Feldnamen füllen
oIni:WriteString(self:cSection, cName, AllTrim(cWidth))
ENDIF
NEXT
cFields := array2string(acFields,",")
oIni:WriteString(self:cSection, "FelderReihenfolge", cFields)
Wolfgang
[toc] | [prev] | [next] | [standalone]
| From | "Er!k \\/!$$Er" <nospam@nospam.url> |
|---|---|
| Date | 2012-12-28 20:01 +0100 |
| Message-ID | <ak68knF19lmU1@mid.individual.net> |
| In reply to | #4524 |
Hi Dick, I think I would pass the column names in the bBrowser:Use() . That would solve the time consuming moving. Erik "D.J.W. van Kooten" schreef in bericht 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
[toc] | [prev] | [next] | [standalone]
| From | "Urs Eggmann" <Urs.Eggmann@shinternet.ch> |
|---|---|
| Date | 2012-12-28 22:02 +0100 |
| Message-ID | <ak6fo7F2sh0U1@mid.individual.net> |
| In reply to | #4524 |
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" <public@ic2remove.this.com> 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
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <public@ic2remove.this.com> |
|---|---|
| Date | 2012-12-31 15:28 +0100 |
| Message-ID | <lm63e8hu1hqm94cnphnftft3flgdnlecs7@4ax.com> |
| In reply to | #4524 |
On Fri, 28 Dec 2012 12:26:40 +0100, D.J.W. van Kooten <public@ic2remove.this.com> wrote: Hello Wolfgang, Urs, Erik, >Can anyone recommend a quicker way to re-arrange the columns in a >different order? Thank you very much for the code. I found that rebuilding the bBrowser with your code is around twice as fast, and for some reasons, directly after start over 6 times faster. I think that basically Urs and Wolfgang used the same code. Eriks code is what I normally use (I rebuild the bBrowser with the same code as I build it) but for example in our e-mail program it works differently and any time someone switch boxes it has to be re-built differently. Dick
[toc] | [prev] | [next] | [standalone]
| From | Mathias <mathias.hakansson@consultec.se> |
|---|---|
| Date | 2013-01-07 22:38 -0800 |
| Message-ID | <886762fe-034e-4c77-ab5d-c8090221ea11@googlegroups.com> |
| In reply to | #4535 |
Here is another way to do it. It's fast and does not require that much code... It uses the column name instead of the field name to match columns with settings which I have found to be more practical.
/Mathias
method RestoreDataColumnPositionsAndSizes(symName) class bDataBrowser
local aPandS,a as array
local i,l,j,start as dword
// by Mathias Håkansson
// Resets columnsettings for a bBrowser as they were before.
// symName The symbol name of the window (Usually the class name, but can also be set manually)
aPandS := self:GetDataColumnPositionsAndSizes(symName)
if !Empty(aPandS)
if IsNumeric(aPandS[1])
// First the number for the grid type
self:grid := bGrid{aPandS[1]}
start := 2
if IsSymbol(aPandS[2]) .and. (aPandS[2] != null_symbol)
// Then the setting for the active cell
self:currentmode := aPandS[2]
start := 3
endif
else
start := 1
endif
// Column settings
a := {}
l := ALen(aPandS)
for i := start upto l
j := AScan(self:aoColumn,{|x| x:caption == aPandS[i,1] })
if j != 0
AAdd(a,self:aoColumn[j])
endif
next
if Empty(a)
self:Clear(false)
self:OpenColumn(self:aoColumn)
self:Recalculate()
else
self:Clear(false)
self:OpenColumn(a)
AEval(self:aoColumnOpen,{|x| x:width := aPandS[AScanNamebB(aPandS,x),2] })
self:Recalculate()
endif
endif
return self
method SaveDataColumnPositionsAndSizes(symName) class bDataBrowser
local i,l as dword
local s as string
// by Mathias Håkansson
// Saves the column settings for a bBrowser.
// symName Symbol namne for the window
Default(@symName,ClassName(self:owner))
s := ""
l := dword(self:iColumnOpenCount)
if l > 0
for i := 1 upto l
s += self:aoColumnOpen[i]:caption
s += "{" + AllTrim(Str(self:aoColumnOpen[i]:width)) + "}"
next
MathiasSetRTRegString("bDataColumn properties",Symbol2String(symName),;
AllTrim(Str(self:grid:style)) + Symbol2String(self:currentmode) + "," + s)
endif
return self
method GetDataColumnPositionsAndSizes(symName) class bDataBrowser
local aPandS,aItem as array
local pos,p2,l as dword
local s as string
// by Mathias Håkansson
// Gets column settings for a bBrowser from registry.
// symName Symbol namne for ths window.
Default(@symName,ClassName(self:owner))
aPandS := {}
s := MathiasQueryRTRegString("bDatacolumn properties",Symbol2String(symName))
if IsDigit(String2Psz(CharPos(s,1)))
// First character is a digit. It's the grid style.
AAdd(aPandS,Val(CharPos(s,1)))
s := SubStr(s,2)
// The second is the active cell style. It's a string that should be converted to a symbol
p2 := At(",",s)
if p2 > 0
AAdd(aPandS,String2Symbol(Left(s,p2 - 1)))
s := SubStr(s,p2 + 1)
else
AAdd(aPandS,null_symbol)
endif
endif
l := SLen(s)
pos := 1
while pos <= l
// Column name
p2 := At3("{",s,pos)
aItem := {SubStr3(s,pos,p2 - pos)}
pos := p2 + 1
// Column width
p2 := At3("}",s,pos)
AAdd(aItem,Val(SubStr3(s,pos,p2 - pos)))
pos := p2 + 1
AAdd(aPandS,aItem)
enddo
return aPandS
class bDataWindow inherit DataWindow
// variables
protect auBVField as array
protect auBVFieldOpen as array
export lSaveDataColumnPositionsAndSizes,lSaveWindowSize as logic
method Close(oEvent) class bDataWindow
if self:lSaveDataColumnPositionsAndSizes
self:SaveDataColumnPositionsAndSizes()
endif
if self:lSaveWindowSize
self:SaveWindowSize()
endif
return super:Close(oEvent)
method RestoreDataColumnPositionsAndSizes() class bDataWindow
if (self:browser != null_object) .and. IsMethod(self:browser,#RestoreDataColumnPositionsAndSizes)
self:browser:RestoreDataColumnPositionsAndSizes(ClassName(self))
endif
return self
method SaveDataColumnPositionsAndSizes() class bDataWindow
if (self:browser != null_object) .and. IsMethod(self:browser,#SaveDataColumnPositionsAndSizes)
self:browser:SaveDataColumnPositionsAndSizes(ClassName(self))
endif
return self
method SaveWindowSize(namn) class bDataWindow
local s as string
Default(@namn,Symbol2String(ClassName(self)))
s := AllTrim(Str(self:size:width)) + "," + AllTrim(Str(self:size:height)) + "," + AllTrim(Str(self:origin:x)) + "," +;
AllTrim(Str(self:origin:y))
MathiasSetRTRegString("Window size",namn,s)
return self
method RestoreWindowSize(namn) class bDataWindow
local s as string
local bredd,hojd,x,y as int
local pos1,pos2 as dword
Default(@namn,Symbol2String(ClassName(self)))
s := MathiasQueryRTRegString("Window size",namn)
if !Empty(s)
pos1 := At(",",s)
bredd := Val(Left(s,pos1 - 1))
pos2 := At3(",",s,pos1 + 1)
hojd := Val(SubStr(s,pos1 + 1,pos2 - pos1))
pos1 := pos2
pos2 := At3(",",s,pos1 + 1)
x := Val(SubStr(s,pos1 + 1,pos2 - pos1))
y := Val(SubStr(s,pos2 + 1))
if (x > 0) .and. (y > 0)
self:size := Dimension{bredd,hojd}
self:origin := Point{x,y}
endif
endif
return self
function MathiasQueryRTRegString(skey as string,sSubKey as string) as string
local s as string
* local sOS as string
* sOS := OS()
* if ((sOS = "Windows 9") .or. (sOS = "Windows ME"))
* return QueryRTRegString(skey,sSubKey)
* else
s := GetRegistryValue(HKEY_CURRENT_USER,"Software\\ComputerAssociates\\CA-Visual Objects Applications\\" + skey,sSubKey)
if Empty(s)
return QueryRTRegString(skey,sSubKey)
endif
return s
* endif
procedure MathiasSetRTRegString(skey as string,sSubKey as string,sValue as string)
// if ((OS() = "Windows 9") .or. (OS() = "Windows ME"))
// SetRTRegString(skey,sSubKey,sValue)
// else
SetRegistryValue(HKEY_CURRENT_USER,;
"Software\\ComputerAssociates\\CA-Visual Objects Applications\\" + skey,sSubKey,sValue)
// endif
return
Den måndagen den 31:e december 2012 kl. 15:28:48 UTC+1 skrev D. J. W. van Kooten:
> On Fri, 28 Dec 2012 12:26:40 +0100, D.J.W. van Kooten
>
> <public@ic2remove.this.com> wrote:
>
>
>
> Hello Wolfgang, Urs, Erik,
>
>
>
> >Can anyone recommend a quicker way to re-arrange the columns in a
>
> >different order?
>
>
>
>
>
> Thank you very much for the code. I found that rebuilding the bBrowser
>
> with your code is around twice as fast, and for some reasons, directly
>
> after start over 6 times faster. I think that basically Urs and
>
> Wolfgang used the same code. Eriks code is what I normally use (I
>
> rebuild the bBrowser with the same code as I build it) but for example
>
> in our e-mail program it works differently and any time someone switch
>
> boxes it has to be re-built differently.
>
>
>
> Dick
[toc] | [prev] | [next] | [standalone]
| From | Mathias <mathias.hakansson@consultec.se> |
|---|---|
| Date | 2013-01-07 22:55 -0800 |
| Message-ID | <f9224e3e-a3ce-4a35-8c05-6df0dd63a5c9@googlegroups.com> |
| In reply to | #4558 |
Sorry, forgot these methods:
static function AScanNamebB(a as array,oDataColumn as bDataColumn) as dword
local pos as dword
//pos := AScan(a,{|x| x[1] == oDataColumn:name })
* s := oDataColumn:fieldname
* if Empty(s)
* s := oDataColumn:expression
* endif
pos := AScanExact2Dim1(a,oDataColumn:caption)
return iif(pos == 0,ALen(a),pos)
function AScanExact2Dim1(a as array,s as string) as dword
local l,i as dword
l := ALen(a)
while i < l
++i
if a[i,1] == s
return i
endif
enddo
return 0
/Mathias
Den tisdagen den 8:e januari 2013 kl. 07:38:09 UTC+1 skrev Mathias:
> Here is another way to do it. It's fast and does not require that much code... It uses the column name instead of the field name to match columns with settings which I have found to be more practical.
>
>
>
> /Mathias
>
>
>
> method RestoreDataColumnPositionsAndSizes(symName) class bDataBrowser
>
> local aPandS,a as array
>
> local i,l,j,start as dword
>
>
>
> // by Mathias Håkansson
>
> // Resets columnsettings for a bBrowser as they were before.
>
> // symName The symbol name of the window (Usually the class name, but can also be set manually)
>
>
>
> aPandS := self:GetDataColumnPositionsAndSizes(symName)
>
> if !Empty(aPandS)
>
> if IsNumeric(aPandS[1])
>
> // First the number for the grid type
>
> self:grid := bGrid{aPandS[1]}
>
> start := 2
>
>
>
> if IsSymbol(aPandS[2]) .and. (aPandS[2] != null_symbol)
>
> // Then the setting for the active cell
>
> self:currentmode := aPandS[2]
>
> start := 3
>
> endif
>
> else
>
> start := 1
>
> endif
>
>
>
> // Column settings
>
> a := {}
>
> l := ALen(aPandS)
>
> for i := start upto l
>
> j := AScan(self:aoColumn,{|x| x:caption == aPandS[i,1] })
>
> if j != 0
>
> AAdd(a,self:aoColumn[j])
>
> endif
>
> next
>
> if Empty(a)
>
> self:Clear(false)
>
> self:OpenColumn(self:aoColumn)
>
> self:Recalculate()
>
> else
>
> self:Clear(false)
>
> self:OpenColumn(a)
>
> AEval(self:aoColumnOpen,{|x| x:width := aPandS[AScanNamebB(aPandS,x),2] })
>
>
>
> self:Recalculate()
>
> endif
>
> endif
>
>
>
> return self
>
> method SaveDataColumnPositionsAndSizes(symName) class bDataBrowser
>
> local i,l as dword
>
> local s as string
>
>
>
> // by Mathias Håkansson
>
> // Saves the column settings for a bBrowser.
>
> // symName Symbol namne for the window
>
>
>
> Default(@symName,ClassName(self:owner))
>
>
>
> s := ""
>
> l := dword(self:iColumnOpenCount)
>
> if l > 0
>
> for i := 1 upto l
>
> s += self:aoColumnOpen[i]:caption
>
> s += "{" + AllTrim(Str(self:aoColumnOpen[i]:width)) + "}"
>
> next
>
>
>
> MathiasSetRTRegString("bDataColumn properties",Symbol2String(symName),;
>
> AllTrim(Str(self:grid:style)) + Symbol2String(self:currentmode) + "," + s)
>
> endif
>
>
>
> return self
>
> method GetDataColumnPositionsAndSizes(symName) class bDataBrowser
>
> local aPandS,aItem as array
>
> local pos,p2,l as dword
>
> local s as string
>
>
>
> // by Mathias Håkansson
>
> // Gets column settings for a bBrowser from registry.
>
> // symName Symbol namne for ths window.
>
>
>
> Default(@symName,ClassName(self:owner))
>
>
>
> aPandS := {}
>
>
>
> s := MathiasQueryRTRegString("bDatacolumn properties",Symbol2String(symName))
>
>
>
> if IsDigit(String2Psz(CharPos(s,1)))
>
> // First character is a digit. It's the grid style.
>
> AAdd(aPandS,Val(CharPos(s,1)))
>
> s := SubStr(s,2)
>
>
>
> // The second is the active cell style. It's a string that should be converted to a symbol
>
> p2 := At(",",s)
>
> if p2 > 0
>
> AAdd(aPandS,String2Symbol(Left(s,p2 - 1)))
>
> s := SubStr(s,p2 + 1)
>
> else
>
> AAdd(aPandS,null_symbol)
>
> endif
>
> endif
>
>
>
> l := SLen(s)
>
> pos := 1
>
> while pos <= l
>
> // Column name
>
> p2 := At3("{",s,pos)
>
> aItem := {SubStr3(s,pos,p2 - pos)}
>
> pos := p2 + 1
>
>
>
> // Column width
>
> p2 := At3("}",s,pos)
>
> AAdd(aItem,Val(SubStr3(s,pos,p2 - pos)))
>
> pos := p2 + 1
>
>
>
> AAdd(aPandS,aItem)
>
> enddo
>
>
>
> return aPandS
>
> class bDataWindow inherit DataWindow
>
> // variables
>
> protect auBVField as array
>
> protect auBVFieldOpen as array
>
>
>
> export lSaveDataColumnPositionsAndSizes,lSaveWindowSize as logic
>
> method Close(oEvent) class bDataWindow
>
> if self:lSaveDataColumnPositionsAndSizes
>
> self:SaveDataColumnPositionsAndSizes()
>
> endif
>
> if self:lSaveWindowSize
>
> self:SaveWindowSize()
>
> endif
>
>
>
> return super:Close(oEvent)
>
> method RestoreDataColumnPositionsAndSizes() class bDataWindow
>
> if (self:browser != null_object) .and. IsMethod(self:browser,#RestoreDataColumnPositionsAndSizes)
>
> self:browser:RestoreDataColumnPositionsAndSizes(ClassName(self))
>
> endif
>
>
>
> return self
>
> method SaveDataColumnPositionsAndSizes() class bDataWindow
>
> if (self:browser != null_object) .and. IsMethod(self:browser,#SaveDataColumnPositionsAndSizes)
>
> self:browser:SaveDataColumnPositionsAndSizes(ClassName(self))
>
> endif
>
>
>
> return self
>
> method SaveWindowSize(namn) class bDataWindow
>
> local s as string
>
>
>
> Default(@namn,Symbol2String(ClassName(self)))
>
>
>
> s := AllTrim(Str(self:size:width)) + "," + AllTrim(Str(self:size:height)) + "," + AllTrim(Str(self:origin:x)) + "," +;
>
> AllTrim(Str(self:origin:y))
>
>
>
> MathiasSetRTRegString("Window size",namn,s)
>
>
>
> return self
>
> method RestoreWindowSize(namn) class bDataWindow
>
> local s as string
>
> local bredd,hojd,x,y as int
>
> local pos1,pos2 as dword
>
>
>
> Default(@namn,Symbol2String(ClassName(self)))
>
>
>
> s := MathiasQueryRTRegString("Window size",namn)
>
> if !Empty(s)
>
> pos1 := At(",",s)
>
> bredd := Val(Left(s,pos1 - 1))
>
>
>
> pos2 := At3(",",s,pos1 + 1)
>
> hojd := Val(SubStr(s,pos1 + 1,pos2 - pos1))
>
>
>
> pos1 := pos2
>
> pos2 := At3(",",s,pos1 + 1)
>
> x := Val(SubStr(s,pos1 + 1,pos2 - pos1))
>
>
>
> y := Val(SubStr(s,pos2 + 1))
>
>
>
> if (x > 0) .and. (y > 0)
>
> self:size := Dimension{bredd,hojd}
>
> self:origin := Point{x,y}
>
> endif
>
> endif
>
>
>
> return self
>
> function MathiasQueryRTRegString(skey as string,sSubKey as string) as string
>
> local s as string
>
> * local sOS as string
>
>
>
> * sOS := OS()
>
>
>
> * if ((sOS = "Windows 9") .or. (sOS = "Windows ME"))
>
> * return QueryRTRegString(skey,sSubKey)
>
> * else
>
> s := GetRegistryValue(HKEY_CURRENT_USER,"Software\\ComputerAssociates\\CA-Visual Objects Applications\\" + skey,sSubKey)
>
> if Empty(s)
>
> return QueryRTRegString(skey,sSubKey)
>
> endif
>
>
>
> return s
>
> * endif
>
> procedure MathiasSetRTRegString(skey as string,sSubKey as string,sValue as string)
>
> // if ((OS() = "Windows 9") .or. (OS() = "Windows ME"))
>
> // SetRTRegString(skey,sSubKey,sValue)
>
> // else
>
> SetRegistryValue(HKEY_CURRENT_USER,;
>
> "Software\\ComputerAssociates\\CA-Visual Objects Applications\\" + skey,sSubKey,sValue)
>
> // endif
>
>
>
> return
>
>
>
>
>
> Den måndagen den 31:e december 2012 kl. 15:28:48 UTC+1 skrev D. J. W. van Kooten:
>
> > On Fri, 28 Dec 2012 12:26:40 +0100, D.J.W. van Kooten
>
> >
>
> > <public@ic2remove.this.com> wrote:
>
> >
>
> >
>
> >
>
> > Hello Wolfgang, Urs, Erik,
>
> >
>
> >
>
> >
>
> > >Can anyone recommend a quicker way to re-arrange the columns in a
>
> >
>
> > >different order?
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > Thank you very much for the code. I found that rebuilding the bBrowser
>
> >
>
> > with your code is around twice as fast, and for some reasons, directly
>
> >
>
> > after start over 6 times faster. I think that basically Urs and
>
> >
>
> > Wolfgang used the same code. Eriks code is what I normally use (I
>
> >
>
> > rebuild the bBrowser with the same code as I build it) but for example
>
> >
>
> > in our e-mail program it works differently and any time someone switch
>
> >
>
> > boxes it has to be re-built differently.
>
> >
>
> >
>
> >
>
> > Dick
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <public@ic2remove.this.com> |
|---|---|
| Date | 2013-01-08 09:05 +0100 |
| Message-ID | <vqkne8159dskmd9snk6q38h0qie6bc3a7g@4ax.com> |
| In reply to | #4558 |
On Mon, 7 Jan 2013 22:38:09 -0800 (PST), Mathias <mathias.hakansson@consultec.se> wrote: Hello Mathias, >Here is another way to do it. It's fast and does not require that much code... >It uses the column name instead of the field name to match columns with settings which I have found to be more practical. Thank you; I think all methods presented here contributed to a much faster way of re-showing the columns; we've picked the best from the code shown. Dick
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web