Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RichEditHighlight compatibility with 2.3.7
#1
Hi Gintaras,
Didn't realize they were so many updates since 2.3.3.4 and so just did the 2.3.3.7 update. I use the RichEditHighlight function as below. When I run it after the update, I get four consecutive warnings:

Quote:Warning in RichEditHighlight: This function is obsolete. Will be removed in the future. Instead use __ProcessMemory class. ?

It points to 4 nonconsecutive lines in the code that use the +share or share function:

memset(share 0 sizeof(CHARFORMAT2W))
,CHARFORMAT2W& cfw=+share
,CHARFORMAT2A& cfa=+share
,SendMessage hwndre EM_SETCHARFORMAT SCF_SELECTION share(hwndre)

Is there any easy update. I am not sure I understand how to use the __ProcessMemory class.

Thanks!!,
S

Function RichEditHighlight
Code:
Copy      Help
;/
function hwndre ~findthis [flags] [color] [textcolor] ;;flags: 1 insens, 2 word, 4 regex, 128 bold, 0x100 version 1
;OutCurrentAndThreadEntryMacros
;Highlights all occurences of findthis in a rich edit control. Works in any application.
;hwndre - rich edit control handle.
;findthis - text or regular expression to find.
;flags - combination of these values:
;;;1 - case insensitive
;;;2 - whole word
;;;4 - findthis is regular expression
;;;128 - make bold
;;;0x100 - rich edit control version 1. Version 1 class usually is RICHEDIT. For other versions, class is like RichEdit20A.
;color - highlight color. Not used for version 1 controls.
;textcolor - text color.

;EXAMPLE
;str rx="\bfind this\b"
;int n=RichEditHighlight(id(59648 "WordPad") rx 1|4|128 ColorFromRGB(255 255 128) ColorFromRGB(255 0 0))
;out "Found %i instances" n


def CFM_COLOR 0x40000000
def CFM_BACKCOLOR 0x4000000
def CFM_BOLD 0x1
def CFE_BOLD 0x1
def SCF_SELECTION 1
def EM_GETTEXTMODE (WM_USER + 90)
;type CHARFORMATA cbSize dwMask dwEffects yHeight yOffset crTextColor !bCharSet !bPitchAndFamily !szFaceName[LF_FACESIZE]
;type CHARFORMAT2A :CHARFORMATA'v1 @wWeight @sSpacing crBackColor lcid dwReserved @sStyle @wKerning !bUnderlineType !bAnimation !bRevAuthor
;type CHARFORMATW cbSize dwMask dwEffects yHeight yOffset crTextColor !bCharSet !bPitchAndFamily @szFaceName[LF_FACESIZE]
;type CHARFORMAT2W :CHARFORMATW'v1 @wWeight @sSpacing crBackColor lcid dwReserved @sStyle @wKerning !bUnderlineType !bAnimation !bRevAuthor
dll user32 #IsWindowUnicode hWnd

ARRAY(CHARRANGE) a; int i
str s.getwintext(hwndre); if(!s.len) ret
if(flags&0x100=0) s.findreplace("[]" "[10]")

if(flags&4)
,if(findrx(s findthis 0 flags&3|4|8|16 a)<0) ret
else
,a.create(1 0)
,rep
,,if(flags&2) i=findw(s findthis i 0 flags&1)
,,else i=find(s findthis i flags&1)
,,if(i<0) break
,,CHARRANGE& cr=a[0 a.redim(-1)]
,,cr.cpMin=i; i+findthis.len; cr.cpMax=i
,if(!a.len) ret

int ver1=flags&0x100 and !SendMessage(hwndre EM_GETTEXTMODE 0 0)
memset(share 0 sizeof(CHARFORMAT2W))
if(IsWindowUnicode(hwndre))
,CHARFORMAT2W& cfw=+share
,if(ver1) cfw.cbSize=sizeof(CHARFORMATW)
,else cfw.cbSize=sizeof(CHARFORMAT2W); if(color) cfw.dwMask|CFM_BACKCOLOR; cfw.crBackColor=color
,if(textcolor) cfw.dwMask|CFM_COLOR; cfw.crTextColor=textcolor
,if(flags&128) cfw.dwMask|CFM_BOLD; cfw.dwEffects=CFE_BOLD
else
,CHARFORMAT2A& cfa=+share
,if(ver1) cfa.cbSize=sizeof(CHARFORMATA)
,else cfa.cbSize=sizeof(CHARFORMAT2A); if(color) cfa.dwMask|CFM_BACKCOLOR; cfa.crBackColor=color
,if(textcolor) cfa.dwMask|CFM_COLOR; cfa.crTextColor=textcolor
,if(flags&128) cfa.dwMask|CFM_BOLD; cfa.dwEffects=CFE_BOLD

for i 0 a.len
,SendMessage hwndre EM_SETSEL a[0 i].cpMin a[0 i].cpMax
,SendMessage hwndre EM_SETCHARFORMAT SCF_SELECTION share(hwndre)

SendMessage hwndre EM_SETSEL 0 0
ret a.len
#2
updated here:
Find and highlight text in other app using regular expresion


Forum Jump:


Users browsing this thread: 1 Guest(s)