Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checkbox caption
Message
From
12/06/2008 05:45:02
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
12/06/2008 04:54:26
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01322765
Message ID:
01323382
Views:
25
Hallo Christian,

you have changed the UsePrecision to .F. to improve the PathEllipse problem?
Changed nothing on my comp. Still no ellipsis in path, the call to MeasureString returns len(lcText)

What mostly works is
*...
  m.loFormat.Trimming       = IIF(lnTrimMode=StringTrimmingEllipsisPath,StringTrimmingEllipsisCharacter,tnTrimMode)
*...
*but this not perfect

Anyway some improvements.
*calculate the gaps for some objects
*this is what looks closest on my comp, (using your approach)
*one might add an extra pixel of width if one likes a gap on the right border.
*its mianly done with a string [i[i[i[i[i[i[i]]]]]]]ppppppppppppppppppppppppppppppppppp as caption
*I run trough all numbers of i so that I found some "bad" states
 DO CASE
  CASE loControl.BASECLASS='Label'
   m.lnWidth  = m.loControl.WIDTH-8
   m.lnHeight = m.loControl.HEIGHT
  CASE loControl.BASECLASS='Commandbutton'
   m.lnWidth  = m.loControl.WIDTH-13
   m.lnHeight = m.loControl.HEIGHT
  CASE loControl.BASECLASS='Checkbox' AND toObject.STYLE=0
   m.lnWidth  = m.loControl.WIDTH-22
   m.lnHeight = m.loControl.HEIGHT
  CASE loControl.BASECLASS='Checkbox'
   m.lnWidth  = m.loControl.WIDTH-13
   m.lnHeight = m.loControl.HEIGHT
  CASE loControl.BASECLASS='Optionbutton' AND toObject.STYLE=0
   m.lnWidth  = m.loControl.WIDTH-22
   m.lnHeight = m.loControl.HEIGHT
  CASE loControl.BASECLASS='Optionbutton'
   m.lnWidth  = m.loControl.WIDTH-13
   m.lnHeight = m.loControl.HEIGHT
  CASE loControl.BASECLASS='Header'
   m.lnWidth  = m.loControl.PARENT.WIDTH-8
   m.lnHeight = m.loControl.PARENT.PARENT.HEADERHEIGHT
  OTHERWISE
   RETURN m.lcText
 ENDCASE
>Hello Agnes,
>
>here is an updated version, which fixes the Path elipsis problem.
>
>The margins of the individual controls have to be figured out by trial and error.
>
>
>#DEFINE CHECKBOXMARGIN_STYLE_0 16
>#DEFINE CHECKBOXMARGIN_STYLE_1 4
>
>#DEFINE StringTrimmingNone    0
>#DEFINE StringTrimmingCharacter   1
>#DEFINE StringTrimmingWord    2
>#DEFINE StringTrimmingEllipsisCharacter 3
>#DEFINE StringTrimmingEllipsisWord  4
>#DEFINE StringTrimmingEllipsisPath  5
>
>FUNCTION FitTextToControl
>	LPARAMETERS loControl, lcText, lnTrimMode
>
>	LOCAL lnHeight, lnWidth
>	LOCAL loFont as xfcFont
>	LOCAL loBmp as xfcBitmap
>	LOCAL loGfx AS xfcGraphics
>	LOCAL loFormat AS xfcStringFormat
>	LOCAL loSize AS xfcSize, loRect as xfcSize
>	LOCAL lcText, lnCharCount, lnOrigTrimMode
>	
>	m.lnCharCount = 0
>	m.lnWidth = m.loControl.Width
>	m.lnHeight = m.loControl.Height
>
>	DO CASE
>		CASE m.loControl.BaseClass = 'Checkbox'
>			m.lnWidth = m.lnWidth - IIF(m.loControl.Style = 0, CHECKBOXMARGIN_STYLE_0, CHECKBOXMARGIN_STYLE_1)
>		CASE m.loControl.BaseClass = 'Combobox'
>			&& ...
>		CASE m.loControl.BaseClass = 'Label'
>			&& ...
>	ENDCASE
>
>	m.lnOrigTrimMode = m.lnTrimMode
>	IF m.lnTrimMode = StringTrimmingEllipsisPath
>		m.lnTrimMode = StringTrimmingCharacter
>	ENDIF
>	
>	WITH _SCREEN.System.Drawing		
>		m.loFont = .Font.New(m.loControl.Fontname, m.loControl.Fontsize, 0, .GraphicsUnit.Point)
>		m.loBmp = .Bitmap.New(1,1)
>		* Retrieve the graphics object.
>		m.loGfx = .Graphics.FromImage(m.loBmp)
>		m.loGfx.InterpolationMode = .Drawing2D.InterpolationMode.NearestNeighbor
>		m.loGfx.SmoothingMode = .Drawing2D.SmoothingMode.AntiAlias
>		m.loGfx.UsePrecision = .F. && !!! this gives better results !!!
>		m.loRect = .Size.New(m.lnWidth, m.lnHeight)
>		m.loFormat = .StringFormat.GenericTypographic
>		m.loFormat.ALIGNMENT = .Stringalignment.Near
>		m.loFormat.Linealignment = .Stringalignment.Near
>		m.loFormat.Trimming = m.lnTrimMode
>		* Measure the String
>		m.loGfx.MeasureString(m.lcText, m.loFont, m.loRect, m.loFormat, @m.lnCharCount)
>	ENDWITH	
>
>	 DO CASE
>	 	CASE LEN(m.lcText) <= m.lnCharCount
>	   		RETURN m.lcText
>	  	CASE INLIST(m.lnOrigTrimMode, StringTrimmingEllipsisCharacter, StringTrimmingEllipsisWord)
>	   		RETURN SUBSTR(m.lcText, 1, m.lnCharCount) + '...'
>	  	CASE m.lnOrigTrimMode = StringTrimmingEllipsisPath
>	   		RETURN DISPLAYPATH(m.lcText, m.lnCharCount)
>	  	OTHERWISE
>	   		RETURN SUBSTR(m.lcText, 1, m.lnCharCount)
>	 ENDCASE
>
>ENDFUNC
>
>
>Christian
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform