You need to use oCol:bPaintText and paint the text and border of the cells the way you want.
The border with specific width and color are shown only on edit-cells
and can differ any column.
i will show the border only around the actual cell to edit and only if this cell has focus!
#include "fivewin.ch"
STATIC lDel := .F., nColRow := 1
FUNCTION MAIN()
local oWnd, oBrw, oFont, oBold
USE WWONDERS NEW
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "VERDANA" SIZE 0,-13 BOLD
DEFINE WINDOW oWnd TITLE "Image and Text in same cell"
oWnd:SetFont( oFont )
@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE "WWONDERS" ;
COLUMNS "NAME","DETAILS" COLSIZES 200, 250 ;
LINES NOBORDER
WITH OBJECT oBrw
:nRowHeight := 200
oBrw:bChange := { || MOVEBORDER( oBrw ) }
oBrw:lHoverSelect := .T. // autofocus
WITH OBJECT :aCols[ 1 ]
:bStrImage := { || FIELD->IMAGE }
:oDataFont := oBold
:nDataStrAlign := AL_CENTER + AL_BOTTOM
:nDataBmpAlign := AL_CENTER
:aImgRect := { nil, nil, -40, nil }
END
//
:CreateFromCode()
END
oWnd:oClient := oBrw
oWnd:nHeight := 700
oBrw:bPainted := < |hDC|
// CELL_BORDER( oBrw, hDC, nColumn, nRow, nRGBColor, nCellPen, lDel )
CELL_BORDER( oBrw, hDC, 1, nColRow, 255, 10, lDel )
RETURN NIL
>
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont, oBold
RETURN NIL
//----------------------------
FUNCTION MOVEBORDER( oBrw )
IF oBrw:nColSel = 1
lDel := .T.
oBrw:Refresh()
lDel := .F.
nColRow := oBrw:nRowSel
ELSE
lDel := .T.
ENDIF
oBrw:Refresh()
RETURN NIL
// -------------
FUNCTION CELL_BORDER( oBrw, hDC, nCol, nRow, nRGBColor, nCellPen, lDel )
LOCAL oGraphics := Graphics():New( hDC )
LOCAL nRed := nRGBRed( nRGBColor )
LOCAL nGreen := nRGBGreen( nRGBColor )
LOCAL nBlue := nRGBBlue( nRGBColor )
LOCAL oPen := Pen():New( 255, nRed, nGreen, nBlue, nCellPen )
LOCAL aRect := oBrw:aCellCoor( nRow, nCol ) // --> { nTop, nLeft, nBottom, nRight }
LOCAL nLeft := oBrw:aCols[ nCol ]:nDisplayCol - nCellPen
LOCAL nWidth := oBrw:ColAtPos( nCol ):nWidth() + nCellPen + 3
LOCAL nHeight := oBrw:nRowHeight + nCellPen + 3
IF lDel = .F.
oGraphics:DrawRect( oPen, ,nLeft, aRect[1] - nCellPen +2, nWidth, nHeight )
ELSE
oGraphics:DrawRect( oPen, ,nLeft, aRect[1] - nCellPen, 0, 0 )
ENDIF
oPen:Destroy()
oGraphics:Destroy()
RETURN NIL
# maybe you have not switched the compiler to C++!
# Add the switch -P to your compiler. (Borland)
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Silvio.Falconi and 52 guests