dc_findbrowse

This forum is for eXpress++ general support.
Post Reply
Message
Author
MIGUELON
Posts: 141
Joined: Wed Feb 10, 2010 10:55 am

dc_findbrowse

#1 Post 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

Wolfgang Ciriack
Posts: 488
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: dc_findbrowse

#2 Post 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
_______________________
Best Regards
Wolfgang

MIGUELON
Posts: 141
Joined: Wed Feb 10, 2010 10:55 am

Re: dc_findbrowse

#3 Post 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
SEEK.jpg (255.71 KiB) Viewed 1617 times

User avatar
rdonnay
Site Admin
Posts: 4828
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: dc_findbrowse

#4 Post 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.
The eXpress train is coming - and it has more cars.

MIGUELON
Posts: 141
Joined: Wed Feb 10, 2010 10:55 am

Re: dc_findbrowse

#5 Post 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.

Wolfgang Ciriack
Posts: 488
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: dc_findbrowse

#6 Post 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 ?
_______________________
Best Regards
Wolfgang

Post Reply