Hello
I would like to show different fonts in the same cell with xbrowse.
I remember seing something like this from Otto, i have searched but couldn't find it
If anyone knows how we can acheive this,
Thanks for the help,
Richard
#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' + CRLF + ;
'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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 85 guests