box align question

Post Reply
User avatar
Silvio.Falconi
Posts: 7110
Joined: Thu Oct 18, 2012 7:17 pm

Re: box align question

Post by Silvio.Falconi »

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)
the problem comes when i have the first parameter equal to 4


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
how it is used

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)
and I tried and it make this error I not understood

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 )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Post Reply