Can someone tell me how to determine the xpos (and perhaps other info, such as width) of a browse column during runtime? Many years ago, I wrote an app or 2 that displayed a string control below the browse list that displayed the sum or a column, for instance. If the user resized any of the columns, I had the total string move along with the new column position. That was long ago, and I don’t recall how I did that.
So, I imagine I need to know the embed point and how to read the properties of a column to get its position.
TIA
You could take the List Xpos plus the sum of all the columns on the left, but that will be off by the gap between the columns, so not accurate. To get it perfect you put an EIP field into the cell and get the XPos of that EIP.
Here is some code extracted from a bunch of code so not sure I got it all of it:
ColXPos LONG
ColX USHORT
DevTipEIP LONG
ListXPos LONG
CODE
IF ~DevTipEIP THEN !EIP already created
DevTipEIP=CREATE(0,CREATE:Button)
END
ListXPos=ListFEQ{PROP:XPos}
ColX = column number wanted
ListFEQ{PROP:Edit,ColX}=DevTipEIP !Create EIP Control over cell
GETPOSITION(DevTipEIP,ColXPos,cY#,cw#,ch#) !Get EIP Position of cell, relative
ListFEQ{PROP:Edit,ColX}=0 !Remove EIP
ColXPos = ColXPos + ListXPos !EIP XPos is relative to List X
@jslarve had the idea that below the LIST you add another LIST one row high to show the totals. It has about the same FORMAT as the original. it is FROM a Queue with one record holding the totals. Any column resizing on the detail list has to be made in the Total LIST, so watch for EVENT:ColumnResize. I think it was an article in Clarion Mag so search that for author Jeff Slarve.
My code above is from my Window Preview class that has a “DevTips” feature that adds a tip to each list column which shows many properties including XPos:
Carl -
Thanks for the quick reply. I got what I need from your post, and basically have things working with a bit more tweaking to do. The second list idea is 1 I’ll try out as well.
Searching ClarionMag I found the below two. I’m on my phone so cannot open.
Positioning List Box Totals
2002-06-11
Sometimes you’ll want to place total fields below list boxes and in some cases those totals need to be positioned exactly below a column. This is easy if the user doesn’t resize any columns but what if you do allow resizing? Brice Schagane shows how to align the total fields with the columns at runtime
The Clarion Advisor: Displaying List Totals 2000-11-14
One of the tricks of productive programming is to not let yourself be limited by the standard ways of solving a particular problem. Here’s a novel solution to displaying column totals underneath a list box.
Carl -
I’ve found the Clarion Magazine back issues on clarionmag.com, and the article concerning the list totals. That article refers to a source code download (apparently) named v2n11totals.zip. Is there a repository somewhere for the downloads that accompany these old articles?
Thanks
One problem I would have with the Total List is often the totals need 1.5x - 2x the width so with STRINGs I end up putting them on 2 lines staggered.
I know there are downloads … If you click around the links you’ll find this page with all downloads:
https://clarionmag.jira.com/wiki/spaces/archive/pages/399459/Monthly+PDFs+and+source+ZIPs
I downloaded cmag-2000-11.zip with all “extras” and inside that was your file that I attached.
v2n11totals.zip (1.2 KB)
v4n06totals.zip (29.0 KB)
PROGRAM
map
FillQ1()
end
ListTotalClass Class,Type
InListYOffset byte(2)
InList Short
TotalList Short
CopyFormat Procedure
Init Procedure(Short InList,Short TotalList)
SynchColumns Procedure(Byte RightToLeft=False)
TakeEvent Procedure
end
LT ListTotalClass
Q1 Queue
S1 String(20)
D1 Decimal(10,2)
D2 Decimal(10,2)
D3 Decimal(10,2)
D4 Decimal(10,2)
end
Q2 Queue(Q1)
end
Window WINDOW('Listbox Totalling'),AT(,,284,152),FONT('MS Sans Serif',8,,),CENTER,SYSTEM,GRAY,DOUBLE
LIST,AT(5,5,272,129),USE(?List1),VSCROLL,FORMAT('55L(2)|M~Column 1~C(0)52R(2)|M~Column 2~C(0)@[email protected](2)|M~Column 3~C(0)@n-10' &|
'[email protected](2)|M~Column 4~C(0)@[email protected](2)|M~Column 5~C(0)@[email protected]'),FROM(Q1)
LIST,AT(9,137,241,10),USE(?List2),NOBAR,VSCROLL,COLOR(COLOR:BTNFACE),FORMAT('20L(2)|M'),FROM(Q2)
END
Code
FillQ1()
Open(Window)
LT.Init(?List1,?List2)
Accept
LT.TakeEvent
end
FillQ1 PRocedure
Ndx Long
Code
Free(Q1)
Clear(Q1)
Free(Q2)
Clear(Q2)
Q2.S1 = 'Total'
Loop Ndx = 1 to 14
Q1.S1 = 'Record ' & Ndx
Q1.D1 = Random(1,500000) * .01
Q1.D2 = Random(1,500000) * .01
Q1.D3 = Random(1,500000) * .01
Q1.D4 = Random(1,500000) * .01
Add(Q1)
Q2.D1 += Q1.D1
Q2.D2 += Q1.D2
Q2.D3 += Q1.D3
Q2.D4 += Q1.D4
end
Add(Q2)
ListTotalClass.CopyFormat Procedure
Ndx Long
Code
Self.TotalList{PROP:Format} = Self.InList{PROP:Format}
Self.TotalList{PROP:XPos} = Self.InList{PROP:XPos}
Self.TotalList{PROP:YPos} = Self.InList{PROP:YPos} + Self.InList{PROP:Height} + Self.InListYOffset
Self.TotalList{PROP:Width} = Self.InList{PROP:Width}
Loop Ndx = 1 to 255
If NOT Self.TotalList{PROPList:Exists,Ndx} then break.
Self.TotalList{PROPList:Header,Ndx}=''
end
ListTotalClass.Init Procedure(Short InList,Short TotalList)
Code
Self.InList = InList
Self.TotalList = TotalList
Self.CopyFormat
ListTotalClass.SynchColumns Procedure(Byte RightToLeft=False)
Ndx Long
Code
Loop Ndx = 1 to 255
If NOT Self.TotalList{PROPList:Exists,Ndx} then break.
If RightToLeft
Self.TotalList{PROPList:Width,Ndx} = Self.InList{PROPList:Width,Ndx}
else
Self.InList{PROPList:Width,Ndx} = Self.TotalList{PROPList:Width,Ndx}
end
end
ListTotalClass.TakeEvent Procedure
Code
If Event() = Event:ColumnResize
Case Field()
of Self.InList
Self.SynchColumns(1)
of Self.TotalList
Self.SynchColumns
end
end
Thank you once again!