FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Richedit how to highlight a defined word in memofields ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Richedit how to highlight a defined word in memofields ?
Posted: Tue Feb 06, 2018 07:48 AM
Hello,

I want to highlight a defined word inside a memofield
from a selected record in xbrowse.
Maybe a solution using < At > and < Textout > :-)

@ 10,20 XBROWSE oBrw SIZE 580, -75 PIXEL OF oDlg ;
COLUMNS "TOPICNO", "FORUM", "LIKE", "T_DELETE", "DATE", "AUTHOR", "INFO" ;
COLSIZES 50, 60, 45, 45, 70, 120, 110 ;
HEADERS "No.", "Forum", "Like", "Del.", "Date", "Author", "Filter or Info" ;
AUTOSORT LINES NOBORDER FONT oMono ;
ALIAS cFileName UPDATE


WITH OBJECT oBrw
:nMarqueeStyle := MARQSTYLE_HIGHLROWRC
:bChange := { || cTCode := (cFileName)->CODE, oTCode:Refresh(), ; include the highlight function :-)
cLink := ALLTRIM((cFileName)->LINK), oLink:Refresh(), ;
cTopic := ALLTRIM((cFileName)->TOPIC), oTopic:Refresh(), ;
nGoRecord := (cFileName)->(RECNO()) }

@ 40, 610 GET oTCode VAR cTCode SIZE 590, 420 PIXEL OF oDlg ; // w h
MEMO READONLY HSCROLL FONT oMono UPDATE




any idea ?

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to highlight a defined word in memofields ?
Posted: Tue Feb 06, 2018 08:56 AM

Try using a richtext edit control instead of a multiline edit.

EMG

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to highlight a defined word in memofields ?
Posted: Tue Feb 06, 2018 09:04 AM

Enrico,

do You have any sample for it to do this on a xbrowse-recordchange ?

regards
Uwe :?:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to highlight a defined word in memofields ?
Posted: Tue Feb 06, 2018 09:07 AM

No, sorry.

EMG

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to highlight a defined word in memofields ?
Posted: Tue Feb 06, 2018 09:43 AM

Uwe,

Please review FWH/source/function/memoedit.prg and look there for function RichEdit()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: How to highlight a defined word in memofields ?
Posted: Thu Feb 08, 2018 11:12 AM

Antonio,

I don't see any code there that can be used ?

There is a line that calls a .DLL Are funtions insite there ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: How to highlight a defined word in memofields ?
Posted: Thu Feb 08, 2018 11:48 AM

Uwe,

We may be looking into the sample

testrtf = code with 1 word highlighted

testrtf5 and find a way there, using richedit as function to browse (show) the data.

Unless someone has done this :: Otto has !

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: How to highlight a defined word in memofields ?
Posted: Thu Feb 08, 2018 12:38 PM

In this topic :

viewtopic.php?f=3t=34703hilit=xml

There is a sample in replacing text in XML. Maybe also a possibility

&&

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to highlight a defined word in memofields ?
Posted: Thu Feb 08, 2018 12:53 PM
Code (fw): Select all Collapse
METHOD Colorize( nStart, nEnd, nColor ) CLASS TRichEdit

   ::SetSel( nStart, nEnd )
   RESetCharFormat( ::hWnd, ::oFont:cFaceName, ;
                    Size2Font( ::oFont:nHeight ) * 20, nColor, ;
                    ::oFont:nCharSet, ;
                    ::oFont:nPitchFamily, ;
                    ::oFont:nWeight, ;
                    ::oFont:lItalic, ;
                    ::oFont:lUnderline, ;
                    ::oFont:lStrikeOut )
   ::HideSel()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: How to highlight a defined word in memofields ?
Posted: Thu Feb 08, 2018 01:29 PM
It is not my cup of thea, but maybe also with this function something can be done ?

cFind = "Xbrowse"
cText = ((XLM code color)) + "Xbrowse" + ((XLM code endcolor))

and the function below will do it ?

Code (fw): Select all Collapse
METHOD ReplaceAll( lUndo, cFind, lDown, lCase, lWord, lAll, cText, lMsg ) CLASS TRichEdit5
   
   local   lSw   := .T.
   local   nV    := 0
   local   nPos  := ::GetPos()
   
   DEFAULT lUndo := .T.
   DEFAULT lMsg  := .T.

   Do While lSw
      lSw := ::Find( cFind, lDown, lCase, lWord )
      if lSw
         nV++
         ::ReplaceSel( lUndo, cText )
      endif
   Enddo
   if !Empty( nV )
      if lMsg
         MsgInfo( "End Replace: " + StrZero( nV, 5 ) + " found" )
      endif
   else
      MsgInfo("String not found: " + cFind )
   endif
   ::SetPos( nPos )

return if( !Empty( nV ), .T., .F. )
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: How to highlight a defined word in memofields ?
Posted: Sat Feb 17, 2018 05:06 PM

It is possible that this may help

viewtopic.php?f=3t=35259#p209984

&

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: How to highlight a defined word in memofields ?
Posted: Sat Feb 17, 2018 05:52 PM
Is the 5 version a upgrade ?

this code works, but in simple code. Not fancy.

Works with sample dir.

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "RichEdit.ch"

function Main()

  local cTitle:="Test"
  local cResult, oMemo
  Public cShowstr:=""
  Public oDlg

  REQUEST DBFCDX

   USE clients via "DBFCDX" NEW

   DEFINE FONT oFont NAME "Courier New" SIZE 8,15
   DEFINE FONT oBold NAME "Courier New" BOLD SIZE 8,15

   DEFINE DIALOG oDlg FROM 5,10 TO 50, 200 font oFont TITLE "Test Color"

   @ 10, 10 XBROWSE oBrw OF oDlg ;
      SIZE 400, 200 PIXEL ;
      COLUMNS 'Name', 'Adress', 'Notes' ;
      ALIAS 'CLIENTS' NOBORDER

   WITH OBJECT oBrw

      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS

      :bChange := { || oSay:refresh(),showmemo() }

      :CreateFromCode()
   END

   @ 10,460 SAY oSay PROMPT clients->notes SIZE 200,200 PIXEL OF oDlg COLOR CLR_BLACK update  //TRANSPARENT

   ACTIVATE DIALOG oDlg CENTERED

   close all
Return nil

function showmemo()
   Local cStr:=""
   local cChange:= "FiveWin"   //  Word that we will look for
   local cInto:= "\cf2 FiveWin \cf1"  // Put Word in Color


   cText = alltrim(clients->notes)

   cStr  += "{\rtf1\ansi\deff0"
   cStr  += "{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}"
   cstr  = cStr + cText
   cStr  += "}"

   cShowStr = StrTran( cStr, cChange, cInto )  // --> "Harbour Power"

   hDLL = LoadLibrary( 'riched20.dll' )
   @ 250,900 RICHEDIT oMemo VAR cShowstr of oDlg PIXEL SIZE 300,400

return NIL
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: How to highlight a defined word in memofields ?
Posted: Sat Feb 17, 2018 05:57 PM
Please try with new control

Code (fw): Select all Collapse
#include "RichEdit5.ch"


    // hDLL = LoadLibrary( 'riched20.dll' )              // Not use this
   @ 250,900 RICHEDIT5 oMemo VAR cShowstr of oDlg PIXEL SIZE 300,400


Continue in
viewtopic.php?f=3&t=35301&start=0#p210159
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to highlight a defined word in memofields ?
Posted: Mon Mar 19, 2018 11:45 AM
Christobal,

I got the defined hightlighted words from MEMO displayed.
There are some problems :

1. different typings "xBrowse" found "XBROWSE" not found
2. The MEMO is displayed in just one line NO working linefeed with defined HSCROLL
-- without HSCROLL no formatted text.
3. NO edit possible ( textchange is needed ) .
4. what happens with multiple findings ( a scan must be included ) ?

Is there still something that must be included ?

Code (fw): Select all Collapse
FUNCTION SHOWMEMO(cText, oFont, cFSeek1, cFSeek2)
LOCAL cStr      := ""
LOCAL cChange   := "xbrowse"                //  Word that we will look for
LOCAL cInto     := "\highlight1 xbrowse \highlight0"  // Put Word in Color
LOCAL cVar      := ""

cStr    += "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang3082{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}"
cStr    += "{\colortbl ;\red255\green0\blue0;\red0\green0\blue0;\red128\green64\blue64;\red0\green0\blue128;}"
cStr    += "\viewkind4\uc1"
cStr    += "\pard\fs20" + if( Empty( cText ), " ", cText )
cStr    += "}"
cStr    := STRTRAN( cStr, cChange, cInto )

IF HB_ISNIL( oMemo )
    @ 70, 625 RICHEDIT5 oMemo VAR cVar OF oDlg SIZE 600, 380 ; // w h
    FONT oFont  PIXEL HSCROLL      
ENDIF
oMemo:LoadRTF( cStr, .F. )
oMemo:GoToLine( 1 )

RETURN NIL


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: How to highlight a defined word in memofields ?
Posted: Mon Mar 19, 2018 01:29 PM
Uwe, test it, and tell me

Code (fw): Select all Collapse
   IF HB_ISNIL( oMemo )
       @ 5, 5 RICHEDIT5 oMemo VAR cVar OF oDlg SIZE 350, 300 ;
       FONT oFont  PIXEL //HSCROLL
      oMemo:lHighlight := .t.
   ENDIF
   oMemo:LoadRTF( cStr, .F. )
   oMemo:SetPos( 0 )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces