Page 1 of 1
dc_findbrowse
Posted: Wed Apr 02, 2025 10:38 am
by MIGUELON
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
Re: dc_findbrowse
Posted: Wed Apr 02, 2025 10:46 pm
by Wolfgang Ciriack
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
Re: dc_findbrowse
Posted: Thu Apr 03, 2025 1:42 pm
by MIGUELON
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.

- SEEK.jpg (255.71 KiB) Viewed 6217 times
Re: dc_findbrowse
Posted: Sat Apr 05, 2025 6:02 am
by rdonnay
I have the best customers.
It warms my heart to see you supporting each other.
It's hard to focus on where we are all headed when the train just went off the tracks, but we still have our work to do.
Re: dc_findbrowse
Posted: Sat Apr 05, 2025 11:42 am
by MIGUELON
Thanks for your words Roger, we still have a lot of life left to excite you about making software. Don't lose this enthusiasm, there's always a new idea.
Re: dc_findbrowse
Posted: Sat Apr 05, 2025 11:05 pm
by Wolfgang Ciriack
Hello Miguelon,
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.
I see that in my browses, too.
What two issues do you fix, that it work perfectly ?