Richedit how to highlight a defined word in memofields ?

User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Richedit how to highlight a defined word in memofields ?

Post by ukoenig »

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


Image

any idea ?

regards
Uwe :?:
Last edited by ukoenig on Tue Mar 20, 2018 3:59 pm, edited 4 times in total.
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.
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: How to highlight a defined word in memofields ?

Post by Enrico Maria Giordano »

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

EMG
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: How to highlight a defined word in memofields ?

Post by ukoenig »

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.
User avatar
Antonio Linares
Site Admin
Posts: 42520
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: How to highlight a defined word in memofields ?

Post by Antonio Linares »

Uwe,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to highlight a defined word in memofields ?

Post by Marc Venken »

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
User avatar
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to highlight a defined word in memofields ?

Post by Marc Venken »

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
User avatar
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to highlight a defined word in memofields ?

Post by Marc Venken »

In this topic :

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

There is a sample in replacing text in XML. Maybe also a possibility
Marc Venken
Using: FWH 23.08 with Harbour
User avatar
Antonio Linares
Site Admin
Posts: 42520
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: How to highlight a defined word in memofields ?

Post by Antonio Linares »

Code: Select all | Expand

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
User avatar
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to highlight a defined word in memofields ?

Post by Marc Venken »

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: Select all | Expand


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
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: How to highlight a defined word in memofields ?

Post by cnavarro »

It is possible that this may help

viewtopic.php?f=3&t=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
User avatar
Marc Venken
Posts: 1485
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How to highlight a defined word in memofields ?

Post by Marc Venken »

Is the 5 version a upgrade ?

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

Works with sample dir.

Code: Select all | Expand


#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
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: How to highlight a defined word in memofields ?

Post by cnavarro »

Please try with new control

Code: Select all | Expand


#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
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: How to highlight a defined word in memofields ?

Post by ukoenig »

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: Select all | Expand


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.
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: How to highlight a defined word in memofields ?

Post by cnavarro »

Uwe, test it, and tell me

Code: Select all | Expand



   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
Post Reply