Hi everyone, I'd like to challenge you all with a challenge I don't know how to do.
I'm using a sort of DC_FINDBROWSE() method, but it searches by content. While it works very well, I'd like the string I'm searching for to appear in a different color in the Browse column.
Is this possible?
Example:
seek: mos estamos en una prueba
Greetings
dc_findbrowse
-
- Posts: 487
- Joined: Wed Jan 27, 2010 10:25 pm
- Location: Berlin Germany
Re: dc_findbrowse
You can use the Subclass for a Browse:
Code: Select all
browsedata := {|| field->mystring}
cHeader := ....
cAlias :=
@2.5, 1 DCBROWSE oBrowse SIZE 40, 20 ;
DATA cAlias ;
CURSORMODE XBPBRW_CURSOR_ROW ;
FIT ;
SUBCLASS 'XbpBrowseHighlight()' ;
EVAL {|o| o:UseVisualStyle:=.F.} ;
TABSTOP
DCBROWSECOL DATA browsedata HEADER cHeader WIDTH 80 PARENT oBrowse EVAL {|o| o:DataArea:DrawMode := XBP_DRAW_OWNER}
.....
***************************************
Class XbpBrowseHighlight from DC_XbpBrowse
***************************************
Protected:
Var cHighlight
Exported:
Inline Method destroy()
*********************
::cHighlight := NIL
::DC_XbpBrowse:Destroy()
Return (Self)
Inline Method init(oParent, oOwner, aPos, aSize, aPP, lVisible, oGetList)
*****************************************************************
::DC_XbpBrowse:Init(oParent, oOwner, aPos, aSize, aPP, lVisible, oGetList)
::DrawMode := XBP_DRAW_OWNER
::cHighlight := ''
Return (Self)
Inline Method create(oParent, oOwner, aPos, aSize, aPP, lVisible)
*******************************************************************
::DC_XbpBrowse:Create(oParent, oOwner, aPos, aSize, aPP, lVisible)
Return (Self)
Inline Method customDrawCell(oPS, aInfo)
******************************************
LOCAL xData, nPos, aRect, cSubstr
xData := aInfo[XBP_DRAWINFO_AREA]:GetCell(aInfo[XBP_DRAWINFO_ITEM])
if xData <> NIL .and. (nPos := At(::cHighlight, upper(xData))) > 0
cSubStr := substr(xData, nPos, len(::cHighlight))
oPS:SetColor(iif(aInfo[XBP_DRAWINFO_STATE] == XBP_DRAWSTATE_SELECTED, XBPSYSCLR_MENUHILITE, XBPSYSCLR_WINDOWSTATICTEXT))
GraCaptionStr(oPS, aInfo[XBP_DRAWINFO_RECT], {aInfo[XBP_DRAWINFO_RECT, 3], aInfo[XBP_DRAWINFO_RECT, 4]}, xData)
oPS:SetColor(GRA_CLR_BLUE)
if nPos == 1
GraCaptionStr(oPS, aInfo[XBP_DRAWINFO_RECT], {aInfo[XBP_DRAWINFO_RECT, 3], aInfo[XBP_DRAWINFO_RECT, 4]}, cSubStr)
else
aRect := GraQueryTextBox(oPS, left(xData, nPos - 1))
GraCaptionStr(oPS, {aInfo[XBP_DRAWINFO_RECT, 1] + aRect[3, 1], aInfo[XBP_DRAWINFO_RECT, 2]}, {aInfo[XBP_DRAWINFO_RECT, 3], aInfo[XBP_DRAWINFO_RECT, 4]}, cSubstr)
endif
Return (.F.)
endif
Return (.T.)
Inline Method highlight(cStr)
*******************************
::cHighlight := cStr
::InvalidateRect()
Return (Self)
EndClass
_______________________
Best Regards
Wolfgang
Best Regards
Wolfgang
Re: dc_findbrowse
Hello Wolfgang Ciriack, first of all, thank you very much for your generosity in sharing the code.
I'm sending you a screenshot so you can see how it looks, and you can see that the color change isn't clear in some fields.
Also, I don't know how to send you what I'm looking for. I imagine it's with Method highlight(cStr), but I don't know how to call it because I don't know the OBJECT.
I've cheated to see if it works by initializing the variable ::cHighlight := '100'.
After fixing these two issues, everything works perfectly.
Thank you very much for your help.
I'm sending you a screenshot so you can see how it looks, and you can see that the color change isn't clear in some fields.
Also, I don't know how to send you what I'm looking for. I imagine it's with Method highlight(cStr), but I don't know how to call it because I don't know the OBJECT.
I've cheated to see if it works by initializing the variable ::cHighlight := '100'.
After fixing these two issues, everything works perfectly.
Thank you very much for your help.