How to highlight a defined word in memofields ?

How to highlight a defined word in memofields ?

Postby ukoenig » Tue Feb 06, 2018 7: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


Image

any idea ?

regards
Uwe :?:
Last edited by ukoenig on Tue Feb 06, 2018 9:20 am, edited 1 time 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
ukoenig
 
Posts: 3460
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to highlight a defined word in memofields ?

Postby Enrico Maria Giordano » Tue Feb 06, 2018 8:56 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 6688
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to highlight a defined word in memofields ?

Postby ukoenig » Tue Feb 06, 2018 9: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.
User avatar
ukoenig
 
Posts: 3460
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Re: How to highlight a defined word in memofields ?

Postby Antonio Linares » Tue Feb 06, 2018 9:43 am

Uwe,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 35350
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to highlight a defined word in memofields ?

Postby Marc Venken » 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 17.05 with Harbour
Marc Venken
 
Posts: 395
Joined: Tue Jun 14, 2016 7:51 am

Re: How to highlight a defined word in memofields ?

Postby Marc Venken » 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 17.05 with Harbour
Marc Venken
 
Posts: 395
Joined: Tue Jun 14, 2016 7:51 am

Re: How to highlight a defined word in memofields ?

Postby Marc Venken » Thu Feb 08, 2018 12:38 pm

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 17.05 with Harbour
Marc Venken
 
Posts: 395
Joined: Tue Jun 14, 2016 7:51 am

Re: How to highlight a defined word in memofields ?

Postby Antonio Linares » Thu Feb 08, 2018 12:53 pm

Code: Select all  Expand view
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
Antonio Linares
Site Admin
 
Posts: 35350
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to highlight a defined word in memofields ?

Postby Marc Venken » Thu Feb 08, 2018 1: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: Select all  Expand view

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 17.05 with Harbour
Marc Venken
 
Posts: 395
Joined: Tue Jun 14, 2016 7:51 am

Re: How to highlight a defined word in memofields ?

Postby cnavarro » Sat Feb 17, 2018 5:06 pm

It is possible that this may help

viewtopic.php?f=3&t=35259#p209984
Muchas gracias. Many thanks.
Saludos,Regards

Cristobal Navarro - Harbour (r1601050904) - xHarbour (Build 20150603) - VS 2015/17 - FWH 18.01

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
User avatar
cnavarro
 
Posts: 3990
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: How to highlight a defined word in memofields ?

Postby Marc Venken » Sat Feb 17, 2018 5:52 pm

Is the 5 version a upgrade ?

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

Works with sample dir.

Code: Select all  Expand view

#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 17.05 with Harbour
Marc Venken
 
Posts: 395
Joined: Tue Jun 14, 2016 7:51 am

Re: How to highlight a defined word in memofields ?

Postby cnavarro » Sat Feb 17, 2018 5:57 pm

Please try with new control

Code: Select all  Expand view

#include "RichEdit5.ch"


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

Cristobal Navarro - Harbour (r1601050904) - xHarbour (Build 20150603) - VS 2015/17 - FWH 18.01

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
User avatar
cnavarro
 
Posts: 3990
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 17 guests

cron