You have much more experience with owner-drawing in the Browse than I do.
I'm struggling with trying to get just the highlighted cell to paint without affecting other cells.
The below code works but it causes a lot of flickering.
If I remove the ITEMMARKED clause, then it does not work.
Do you have a solution?
aSort2[1] := GRA_CLR_RED // Sort Selected Color (Foreground) // PC CAW 01-13-05
aSort2[2] := GRA_CLR_PALEGRAY // Sort Selected Color (Background)
aSort2[3] := GRA_CLR_BLACK // Sort Unselectable Color (Foreground)
aSort2[4] := GRA_CLR_PALEGRAY // Sort Unselectable Color (Background)
// aSort2[5] := Nil // No Longer Utilized
// aSort2[6] := Nil // No Longer Utilized
aSort2[7] := GRA_CLR_BLACK // Sort Unselected Color (Foreground) - Able to select
aSort2[8] := GRA_CLR_PALEGRAY // Sort Unselected Color (Background) - Able to select
DC_BrowPres(aBrowPres) // save browse presentation factors
DC_BrowseSort(aSort2)
@ 1.00, 1.00 DCSAY "Find: " GET cSeek0 SAYRIGHT Picture '@!' ;
GETOBJECT oGet ;
GETID "cSeek0" ;
GETTOOLTIP 'Example:; "*PARK" for All Violations; Containing the Letters "PARK"' ;
KEYBLOCK {|a,b,o| o:getData(), oBrowse:invalidateRect(), CodeDtl->(_620Seek(a, b, o, oBrowse, GetList, cIndex, @cSeek0)) }
@ 1.25,40.00 DCSAY {|| cPartial } SAYSIZE 25 PARENT oBrowse COLOR GRA_CLR_RED
@ 1.25,67.50 DCSAY '(enter an "*" before the desired search text to locate a Violation Descriptions containing that text)' ;
SAYSIZE 85 PARENT oBrowse COLOR GRA_CLR_BLUE
There is no InvalidateRect() needed with every ITEMMARKED - this is causing the flickering. The other problem is how the selected cell was retrieved. This works well and without flickering:
#INCLUDE "dcdialog.CH"
#pragma library ("dclipx.lib")
FUNCTION Main()
LOCAL oBrowse, aDir := Directory(), GetList[0], i, oFontLarge
LOCAL bOwnerDraw := {|a,b,o|DrawCellHighlighted(a,b,o,oFontLarge)}
oFontLarge := XbpFont():new():create('12.Lucida Console Bold')
@ 0,0 DCBROWSE oBrowse DATA aDir SIZE 100,10 ;
OWNERDRAW bOwnerDraw ;
/* ITEMMARKED {|a,b,o|InvalidateCellRect(o)} */ ;
COLOR {||IIF(oBrowse:arrayElement%2==0,{nil,GRA_CLR_PALEGRAY},{nil,nil})}
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) WIDTH 10 PARENT oBrowse OWNERDRAW
NEXT
DCREAD GUI FIT TITLE 'Browse Ownerdraw test'
RETURN nil
* -----------
PROC appsys ; RETURN
* -----------
STATIC FUNCTION InvalidateCellRect( oBrowse )
LOCAL i
FOR i := 1 TO oBrowse:colCount
oBrowse:GetColumn(i):dataArea:invalidateRect()
NEXT
RETURN nil
* ------------
FUNCTION DrawCellHighlighted( oPS, aInfo, oBrowse, oFontLarge, oFontNormal )
LOCAL xData, nRow := aInfo[1], aRect := aInfo[XBP_DRAWINFO_RECT], ;
oCell := aInfo[5], oColumn := aInfo[6], lStatus := .t.
IF oCell:isDerivedFrom('DC_MultiLineCellGroup') // It's a header
RETURN .t.
ENDIF
xData := DC_XtoC(aInfo[ XBP_DRAWINFO_AREA ]:getCell( aInfo[ XBP_DRAWINFO_ITEM ] ))
* IF nRow == oBrowse:rowPos .AND. oColumn == oBrowse:getColumn(oBrowse:colPos)
IF !BAnd(aInfo[XBP_DRAWINFO_STATE],XBP_DRAWSTATE_SELECTED) = 0 // selected
oPS:setFont(oFontLarge)
oPS:setColor(GRA_CLR_WHITE,GRA_CLR_DARKPINK)
ELSE
oPS:setColor( IIF( aInfo[ XBP_DRAWINFO_STATE ] = XBP_DRAWSTATE_SELECTED, ;
XBPSYSCLR_MENUHILITE, XBPSYSCLR_WINDOWSTATICTEXT ) )
ENDIF
GraCaptionStr( oPS, aRect, { aRect[3], aRect[4] }, xData )
RETURN .f.
Add: This function does not only draw highlighted cells, but all. If it's only needed for highlighted cells, it should return .F. at the "ELSE"-portion of the function.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Yes, everything is fine now.
The funny thing about that who fiasco was that I would have found the answer if I had just referred to my session samples from my Owner drawing session.
The eXpress train is coming - and it has more cars.
The funny thing about that who fiasco was that I would have found the answer if I had just referred to my session samples from my Owner drawing session.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."