Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checkbox caption
Message
From
12/06/2008 01:03:58
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
11/06/2008 09:17:16
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:
01323366
Views:
23
Hi Christian,

this looks like the solution to my recent problem. Thank you very much.


Just for curiosity:
-it seems to work on each of both style values. Can you confirm that?

Update:
style=1 needs a lower margin. Must have crossed my eyes.

-How do you determine CHECKBOXWIDTHPLUSTEXTMARGINS?
this is because caption is valid for
CheckBox Control
CommandButton Control
Header Object
Label Control (Visual FoxPro)
OptionButton Control

and the not so generic
Page Object
Form Object / _SCREEN System Variable |
ToolBar Object

Ignoring the Form/Page captions, I need to determine the margins for each of those.

-Do you see a better way to get StringTrimmingEllipsisPath then
*...
 DO CASE
  CASE LEN(m.lcText)<=m.lnCharCount
   RETURN m.lcText
  CASE INLIST(m.lnTrimMode, StringTrimmingEllipsisCharacter, StringTrimmingEllipsisWord) AND ;
    LEN(m.lcText) > m.lnCharCount
   RETURN SUBSTR(m.lcText, 1, m.lnCharCount) + '...'
  CASE m.lnTrimMode=StringTrimmingEllipsisPath
   RETURN DISPLAYPATH(m.lcText, 1, m.lnCharCount)
  OTHERWISE
   RETURN SUBSTR(m.lcText, 1, m.lnCharCount)
 ENDCASE
ENDFUNC
Update:
the code above was an untested idea. StringTrimmingEllipsisPath seems not to work.

Agnes
>Hi,
>
>this code based on the GDIPlusX library should get you started.
>
>
>&& prerequisites
>DO system.app && initialize GDIPlusX somewhere
>
>
>
>&& usage example
>Checkbox::SetCaption
>LPARAMETERS lcText
>THIS.Caption = FitTextToCheckbox(THIS, lcText, StringTrimmingEllipsisCharacter)
>
>
>
>#DEFINE CHECKBOXWIDTHPLUSTEXTMARGINS 14
>
>#DEFINE StringTrimmingNone    0
>#DEFINE StringTrimmingCharacter   1
>#DEFINE StringTrimmingWord    2
>#DEFINE StringTrimmingEllipsisCharacter 3
>#DEFINE StringTrimmingEllipsisWord  4
>#DEFINE StringTrimmingEllipsisPath  5
>
>FUNCTION FitTextToCheckbox
>	LPARAMETERS loCheckBox, 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 lnCharCount
>	
>	m.lnCharCount = 0
>	m.lnWidth = m.loCheckBox.Width - CHECKBOXWIDTHPLUSTEXTMARGINS
>	m.lnHeight = m.loCheckBox.Height
>	
>	WITH _SCREEN.System.Drawing		
>		m.loFont = .Font.New(m.loCheckBox.Fontname, m.loCheckBox.Fontsize, 0, .GraphicsUnit.Point) && 0 = FontStyle is missing - complement ....
>		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 = .T.
>		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 = lnTrimMode
>		* Measure the String
>		m.loGfx.MeasureString(m.lcText, m.loFont, m.loRect, m.loFormat, @m.lnCharCount)
>	ENDWITH	
>
>	IF INLIST(m.lnTrimMode, StringTrimmingEllipsisCharacter, StringTrimmingEllipsisWord) AND ;
>		LEN(m.lcText) > m.lnCharCount
>		RETURN SUBSTR(m.lcText, 1, m.lnCharCount) + '...'
>	ELSE
>		RETURN SUBSTR(m.lcText, 1, m.lnCharCount)		
>	ENDIF
>	
>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