Posted by Grant Foraker on February 06, 2008 at 14:53:34: Uploaded files: 1
Lots of trial and error to come up with a "universal" method of setting the column widths for ListViews. Maybe 95% there.
Starting with demos and examples that looked like ...
cosStyle = LVCFMT.LEFT ! Left justify column text
cosCol = 0
cosCtlText$ = "City"
cosWidth = 230
Gosub COS.ListView.InsertTextColumn
I had to try varius values to get the title wide enough for the fifteen character field. 230 was the lowest I could go at 1920x1200. That worked fine but was way to wide when I ran the dialog at 1024x768.
I looked thru the WDL and found
GOSUB COS.GetDialogBaseUnits --> cosWidth, cosHeight
and Getcosw and GetCent
Using Lucida Console, I got a value of 8, 16 and 16 respectively.
The cosw values seemed right (15*16) = 240. Just about what I wanted. Not quite. I found that the cosw values changed when the dialog was launched from a full screen program versus a normal window. So I settled on "Dialog", but I had to find a "multiplier". For 1920x1200 it was easy (15*8)*2.000 = 240. Back to where I started and the column widths didn't change with the under lying cosw settings.
SELECT CASE SCREENSIZE
CASE FROM 0 TO 1023
LET FONTFACT = cosWidth * 1.150
CASE FROM 1024 THRU 1919
LET FONTFACT = cosWidth * 1.600
CASE ELSE
LET FONTFACT = cosWidth * 2.000
ENDSELECT
Before the dialog is opened I do a COS.GetSystemMetrics to determine the physical screen size of the PC. This determines which of my three DLL's to open. Most PC's are 800 or 1024. Mine is 1920. I saved the value as SCREENSIZE. The 2.000, 1.600 and 1.150 are based on trial and error.
The fonts are 18, 12 and 9. I was hoping the multiplier would relate proportionately. Nope.
Now the 10% I don't have. Despite a fixed width font some of the columns come out either too narrow or too wide and I've had to add a "fudge factor".
cosStyle = LVCFMT.CENTER ! Center column text
cosCol = cosCol + 1
cosCtlText$ = "State"
cosWidth = (FONTFACT * 5) + 10
Gosub COS.ListView.InsertTextColumn
State has a five character title and a three character field, so (5*8)*2 = 80 should work. Nope I have to add 10.
cosCol = cosCol + 1
cosCtlText$ = "Address 1"
cosWidth = (FONTFACT * 25) !!!!!!!!!!- 20
Gosub COS.ListView.InsertTextColumn
Address 1 is a twentyfive is OK at (25*8)*2 = 400. But to squeeze out a few more column space on the list I can fudge with a -20.
You can't fudge too much because the screen will end up all "...".
Appreciate any comments or suggestions.
Each file can be a maximum of 1MB in length Uploaded files will be purged from the server on a regular basis.