nageswaragunupudi wrote:If you want center both vertically and horizontally then use "" or nil for cAlign
on my application I have these options
local aAlign :={"left","right","Center","justified"}
local aPosition :={"on top","on bottom","on center"}
and I make this function
sample SetAlign(1,1)
Code: Select all | Expand
Function SetAlign(nAlignOriz,nAlignVert)
local cPosition
local cAlign
//Position
If nAlignOriz >0
DO CASE
Case nAlignOriz=1
cPosition:="T"
Case nAlignOriz=2
cPosition:="B"
Case nAlignOriz=3
cPosition:=""
ENDCASE
else
cPosition:=""
Endif
//Align
IF nAlignVert>0
DO CASE
Case nAlignVert=1
cAlign:="L"
Case nAlignVert=2
cAlign:="R"
Case nAlignVert=3
cAlign:=""
Case nAlignVert=4
cAlign:=""
ENDCASE
else
cAlign:=""
Endif
return (cPosition+cAlign)
Nages why not add also this https://forums.fivetechsupport.com/view ... 33#p163260 ?
I found also this
Code: Select all | Expand
METHOD JustifyText( cText, nLen, oFont, lPixel ) CLASS TPrinter
local cAuxi:=ALLTRIM(cText), nLenPixel:=0, nSpace:=1
local aWords:={}, i:=0, cSubst:="", cSpell:="", lDone:=.T.
for i = 1 to len(cText)
cSubst := SUBST(cText,i,1)
if cSubst = " "
aadd(aWords,cSpell)
cSpell = ""
endif
cSpell += cSubst
next
if .not.empty(cSpell)
aadd(aWords,cSpell)
endif
if len(aWords)=0 .OR. len(aWords)=1
return cText
endif
if lPixel = nil .or. .not.lPixel
nLenPixel = Max( 0, ( nLen * 10 * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset )
else
nLenPixel = nLen
endif
while .T.
cAuxi = ""
lDone = .F.
for i = 1 to len(aWords)
IF i # len(aWords)
cAuxi += aWords[ i ] + SPACE(nSpace)
ENDIF
next
IF ::GetTextWidth( cAuxi, oFont ) >= nLenPixel
lDone = .T.
EXIT
ENDIF
nSpace ++
enddo
IF lDone
cText = cAuxi
ENDIF
return cText
Code: Select all | Expand
DEFINE FONT oFT12N NAME "Arial" SIZE 0,-11 OF oPrn
cFrase = "Quinto Encontro de FiveWiners em Novembro/2007, espero ver todos presentes!"
nLen = 19 \\ largura do A4 com margens
cJustificado = oPrn:JustifyText(cFrase,nLen,oFT12N)
oPrn:CmSay(01,01,cJustificado,oFT12N,NIL,CLR_BLACK)
Code: Select all | Expand
Application
===========
Path and name: C:\Work\errori\justity\test.Exe (32 bits)
Size: 4,433,920 bytes
Compiler version: Harbour 3.2.0dev (r2104281802)
FiveWin version: FWH 22.03
C compiler version: Borland C++ 5.8.2 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 04/14/23, 15:18:29
Error description: Error BASE/1004 Message not found: TPRINTER:JUSTIFYTEXT
Args:
[ 1] = O TPRINTER
Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TPRINTER:ERROR( 0 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
Called from: ../../../tobject.prg => TPRINTER:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => TPRINTER:JUSTIFYTEXT( 0 )
Called from: test.prg => TESTALIGN( 74 )