FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Mostrar caracters ASCII en xBrowse
Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Mostrar caracters ASCII en xBrowse
Posted: Wed Aug 03, 2011 12:53 PM

Hola amigos,

Cómo puedo mostrar caracteres especiales ASCII en xBrowse
Ej: CHR(12)
me muestra <binary>

Gracias por la ayuda

Saludos,

Adhemar

Saludos,



Adhemar C.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mostrar caracters ASCII en xBrowse
Posted: Thu Aug 04, 2011 07:48 PM

You may use oCol:bPaintText to define your own rendering of text inside the cell.
Simple example of usage is provided in \fwh\samples\testxbr6.prg.

If a codeblock is assigned to oCol:bPaintText, xbrowse paints only the background and does not paint the text. Instead calls the user specified codeblock with parameters, oCol, hDC, cData, aRect, aColors, lHighLite.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Re: Mostrar caracters ASCII en xBrowse
Posted: Thu Aug 04, 2011 09:43 PM
Thanks

With the sample show <binary>
Code (fw): Select all Collapse
#include 'fivewin.ch'
#include 'xbrowse.ch'

function main()

   local oDlg, oBrw
   local oFont, oBold, oItalic
   local aData    := {}

   DEFINE FONT oFont   NAME 'TAHOMA' SIZE 0,-12
   DEFINE FONT oBold   NAME 'TAHOMA' SIZE 0,-12 BOLD
   DEFINE FONT oItalic NAME 'TAHOMA' SIZE 0,-12 ITALIC

   AAdd( aData, { 1, 'Otto   ', ;
      'Mr.Otto' +Chr(12)+ CRLF + ;  //Sample
      'deleveloped using multiple fonts in the same cell' } )
   AAdd( aData, { 2, 'Richard', ;
      "MR.OTTO'S" + CRLF + ;
      'work is well appreciated' } )
   AAdd( aData, { 3, 'Chidak ', ;
      'Mr.Richard Chidak' + CRLF + ;
      'also has  similar requirement. But needs to change the library' } )
   AAdd( aData, { 4, 'Antonio', ;
      'FWH' + CRLF + ;
      'Provides easier solution for owner drawing data without changing library code' } )


   DEFINE DIALOG oDlg SIZE 440,440 PIXEL FONT oFont

   @ 10, 10 XBROWSE oBrw ;
      HEADERS 'No', 'Name', 'Text' ;
      SIZE 200, 200 PIXEL ;
      OF oDlg ;
      ARRAY aData AUTOCOLS ;
      LINES

   oBrw:nStretchCol := STRETCHCOL_LAST

   WITH OBJECT oBrw:aCols[3]
      :nHeadStrAlign := AL_CENTER
      :nWidth        := 200
      :bPaintText    := { |oCol, hDC, cText, aCoord| DrawText( oCol, hDC, cText, aCoord, oBold, oItalic ) }
   END

   oBrw:nDataLines := 6
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont
   RELEASE FONT oBold
   RELEASE FONT oItalic

return nil

static function DrawText( oCol, hDC, cText, aCoord, oBold, oItalic )

   local nTop  := aCoord[ 1 ], nLeft := aCoord[ 2 ]
   local nBottom := aCoord[ 3 ], nRight := aCoord[ 4 ]
   local nRow  := nTop
   local cLine, nFontHt, nAt

   nAt      := AT( CRLF, cText )
   if nAt > 0
      cLine    := Left( cText, nAt - 1  )
      oBold:Activate( hDC )
      nFontHt  := GetTextHeight( oCol:oBrw:hWnd, hDC )
      DrawTextEx( hDC, cLine, { nRow, nLeft, nRow + nFontHt + 4, nRight }, 1 ) //oCol:nDataStyle )
      oBold:DeActivate( hDC )
      nRow     += nFontHt + 4
      cLine    := SubStr( cText, nAt + 2 )

   else
      cLine    := cText
   endif

   oItalic:Activate( hDC )
   DrawTextEx( hDC, cLine, { nRow, nLeft, nBottom, nRight }, oCol:nDataStyle )
   oItalic:DeActivate( hDC )


return nil


Regards

Adhemar
Saludos,



Adhemar C.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mostrar caracters ASCII en xBrowse
Posted: Fri Aug 05, 2011 02:06 AM
Please keep this as the first line of code in the function DrawText( ... ), immediately after local declarations:
Code (fw): Select all Collapse
cText := oCol:Value
Regards



G. N. Rao.

Hyderabad, India
Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Re: Mostrar caracters ASCII en xBrowse
Posted: Fri Aug 05, 2011 02:00 PM

Thanks G. N. Rao.

Now its Ok.

Regards,

Adhemar

Saludos,



Adhemar C.

Continue the discussion