1. RE: RichEdit and findText
- Posted by Brian Broker <bkb at cnw.com> Nov 16, 2004
- 549 views
- Last edited Nov 17, 2004
Pete wrote: > > Derek Parnell wrote: > > > > Pete wrote: > > > > > > Its late so I hope someone can supply the answer to my stupid question > > > while I sleep!! > > > I have a RichEdit in which I'm doing a findText. The findText works > > > fine when searching for a single character, but fails to find it if I am > > > searching for more than one character.. > > > > > > i.e in the RichEdit I have "7028" > > > > > > This works fine:- > > > fnd = findText ( RE, "7", {0,-1}, findDown) > > > so does this > > > fnd = findText ( RE, "0", {0,-1}, findDown) > > > but.. > > > fnd = findText ( RE, "7028", {0,-1}, findDown) > > > returns 0 > > > Adding the findWholeWord flag also makes no difference.. > > > > > > I'm sure I'm doing something wrong but I can't see what.. Help! > > > > I think I know the problem. Find the 'findText()' function in > > the win32lib library and replace ... > > > > FT = struct_FINDTEXTEX( range[1], range[2], text, 0, 0 ) > > > > with ... > > > > FT = struct_FINDTEXTEX( range[1], range[2], text, 0, -1 ) > > > > -- > > Derek Parnell > > Melbourne, Australia > > > > Sorry, that didn't help, below is a cut down example (I'm using XP home > in case it makes any difference) > <snip> Did you apply the RichEdit patch in your copy of Win32Lib? This wasn't fixed in 0.60.6 and isn't noted on the patches page. http://tinyurl.com/4655z I don't even know if this would help but thought it worth mentioning. -- Brian
2. RE: RichEdit and findText
- Posted by Pete <pete_stoner at btconnect.com> Nov 16, 2004
- 535 views
- Last edited Nov 17, 2004
Brian Broker wrote: > > Pete wrote: > > > > Derek Parnell wrote: > > > > > > Pete wrote: > > > > > > > > Its late so I hope someone can supply the answer to my stupid question > > > > while I sleep!! > > > > I have a RichEdit in which I'm doing a findText. The findText works > > > > fine when searching for a single character, but fails to find it if I am > > > > searching for more than one character.. > > > > > > > > i.e in the RichEdit I have "7028" > > > > > > > > This works fine:- > > > > fnd = findText ( RE, "7", {0,-1}, findDown) > > > > so does this > > > > fnd = findText ( RE, "0", {0,-1}, findDown) > > > > but.. > > > > fnd = findText ( RE, "7028", {0,-1}, findDown) > > > > returns 0 > > > > Adding the findWholeWord flag also makes no difference.. > > > > > > > > I'm sure I'm doing something wrong but I can't see what.. Help! > > > > > > I think I know the problem. Find the 'findText()' function in > > > the win32lib library and replace ... > > > > > > FT = struct_FINDTEXTEX( range[1], range[2], text, 0, 0 ) > > > > > > with ... > > > > > > FT = struct_FINDTEXTEX( range[1], range[2], text, 0, -1 ) > > > > > > -- > > > Derek Parnell > > > Melbourne, Australia > > > > > > > Sorry, that didn't help, below is a cut down example (I'm using XP home > > in case it makes any difference) > > > <snip> > > Did you apply the RichEdit patch in your copy of Win32Lib? This wasn't > fixed in 0.60.6 and isn't noted on the patches page. > > <a href="http://tinyurl.com/4655z">http://tinyurl.com/4655z</a> > > I don't even know if this would help but thought it worth mentioning. > > -- Brian Tried again after applying patch (I think it was already applied, but did it again..) still fails - worth a try tho. Pete
3. RE: RichEdit and findText
- Posted by Jonas Temple <jtemple at yhti.net> Nov 16, 2004
- 519 views
- Last edited Nov 17, 2004
Pete wrote: > Tried again after applying patch (I think it was already applied, but > did it again..) still fails - worth a try tho. > > Pete > Pete, I have Win32Lib v0.60.6 and this works for me. I reworked your program and this works on this WinXP Pro machine: include win32lib.ew without warning with trace integer res, start object VOID sequence test test = "test 123456\nwsw 6543\nsd 567\nfe 989\nty 123456\nyh 780\nhu 613\n" constant Win = create( Window, "Serial Numbers", 0, Default, Default, 400, 320, 0 ), SF = create( PushButton, "Search", Win, 140,250, 110, 30, 0), RE = create( RichEdit, "", Win , 20, 20, 360, 200,ES_NOHIDESEL), FindWin = create(Window, "Find", Win, 200, 300, 350, 110, {WS_DLGFRAME, WS_SYSMENU, WS_MINIMIZEBOX} ), FindButton = create(PushButton, "Find", FindWin, 230, 10, 100, 25, 0), CancelButton = create(PushButton, "Cancel", FindWin, 230, 40, 100, 25, 0), FindText = create(EditText, "", FindWin, 65, 20, 140, 25, 0), FindPrompt = create(LText, "Find What:", FindWin, 10, 25, 55, 20, 0) --============================================================ procedure FindButtononClick(integer self, integer event, sequence params) sequence SearchText integer Ffnd SearchText = getText(FindText) if length(SearchText) then Ffnd = findText( RE, SearchText, {start, -1}, findDown) if Ffnd != 0 then -- setSelection( RE, {Ffnd, Ffnd + 1} ) setIndex(RE, {Ffnd, Ffnd + length(SearchText)} ) else -- ? Ffnd VOID = message_box("Searched to the end of the document", "String Not Found!",MB_OK) return end if start = Ffnd + length(SearchText) end if end procedure setHandler( FindButton, w32HClick, routine_id("FindButtononClick")) --=========================================================== procedure CancelButtononClick(integer self, integer event, sequence params) closeWindow(FindWin) end procedure setHandler( CancelButton, w32HClick, routine_id("CancelButtononClick")) --============================================================= procedure Search(integer self, integer event, sequence params) start = 0 openWindow(FindWin, Modal) end procedure setHandler( SF, w32HClick, routine_id("Search")) --======================================================= procedure Run(integer self, integer event, sequence params) putStream( RE, StreamText , test ) end procedure setHandler( Win, w32HOpen, routine_id("Run")) --======================================================== WinMain(Win, Normal) Maybe this will help... Jonas Temple http://www.yhti.net/~jktemple
4. RE: RichEdit and findText
- Posted by Brian Broker <bkb at cnw.com> Nov 16, 2004
- 517 views
- Last edited Nov 17, 2004
Jonas Temple wrote: > > Pete wrote: > > Tried again after applying patch (I think it was already applied, but > > did it again..) still fails - worth a try tho. > > > > Pete > > > Pete, > > I have Win32Lib v0.60.6 and this works for me. I reworked your program > and this works on this WinXP Pro machine: > <snip> That still didn't work for me but it does work when I cut out support for RichEdit 5.0. You can check to see what version you are actually using by checking the value of WC_RICHEDIT. Anyway, when I edited w32dll.ew as follows, it worked fine:
global constant riched32 = registerw32Library({"riched20.dll","riched32.dll"}),--{"Msftedit.dll","riched20.dll","riched32.dll"}), -- Rich Edit control WC_RICHEDIT10 = "RICHEDIT", WC_RICHEDIT20 = "RichEdit20A"--, --WC_RICHEDIT50 = "RICHEDIT50W" global sequence WC_RICHEDIT vw32Libraries[riched32][1] = linkDLL(vw32Libraries[riched32][2]) if vw32Libraries[riched32][1][1] = 1 then WC_RICHEDIT = WC_RICHEDIT20--WC_RICHEDIT = WC_RICHEDIT50 elsif vw32Libraries[riched32][1][1] = 2 then WC_RICHEDIT = WC_RICHEDIT10--WC_RICHEDIT = WC_RICHEDIT20 else WC_RICHEDIT = WC_RICHEDIT10 end if
Maybe the lib shouldn't try supporting RichEdit 5.0 until we need some particular feature of 5.0. -- Brian
5. RE: RichEdit and findText
- Posted by Brian Broker <bkb at cnw.com> Nov 16, 2004
- 509 views
- Last edited Nov 17, 2004
I wrote: > > Maybe the lib shouldn't try supporting RichEdit 5.0 until we need some > particular feature of 5.0. > Oops, to avoid any confusion I should be calling it RichEdit 4.1 (the class name was confusing me). -- Brian
6. RE: RichEdit and findText
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 16, 2004
- 522 views
- Last edited Nov 17, 2004
Brian Broker wrote: > > Jonas Temple wrote: > > > > Pete wrote: > > > Tried again after applying patch (I think it was already applied, but > > > did it again..) still fails - worth a try tho. > > > > > > Pete > > > > > Pete, > > > > I have Win32Lib v0.60.6 and this works for me. I reworked your program > > and this works on this WinXP Pro machine: > > > <snip> > > That still didn't work for me but it does work when I cut out support > for RichEdit 5.0. You can check to see what version you are actually > using by checking the value of WC_RICHEDIT. Anyway, when I edited > w32dll.ew as follows, it worked fine: > }}} <eucode> > global constant > riched32 = > > registerw32Library({"riched20.dll","riched32.dll"}),--{"Msftedit.dll","riched20.dll","riched32.dll"}), > > -- Rich Edit control > WC_RICHEDIT10 = "RICHEDIT", > WC_RICHEDIT20 = "RichEdit20A"--, > --WC_RICHEDIT50 = "RICHEDIT50W" > global sequence WC_RICHEDIT > > vw32Libraries[riched32][1] = linkDLL(vw32Libraries[riched32][2]) > if vw32Libraries[riched32][1][1] = 1 then > WC_RICHEDIT = WC_RICHEDIT20--WC_RICHEDIT = WC_RICHEDIT50 > > elsif vw32Libraries[riched32][1][1] = 2 then > WC_RICHEDIT = WC_RICHEDIT10--WC_RICHEDIT = WC_RICHEDIT20 > > else > WC_RICHEDIT = WC_RICHEDIT10 > end if > </eucode> {{{ > Maybe the lib shouldn't try supporting RichEdit 5.0 until we need some > particular feature of 5.0. I'm starting to suspect you are right. It looks as if the new RichEdit stores text as wide-characters (Unicode utf-16 encoding). I'm still looking into it though. I can now read Rich text wide characters but I can't seem to get the Find part for them working. -- Derek Parnell Melbourne, Australia
7. RE: RichEdit and findText
- Posted by Pete <pete_stoner at btconnect.com> Nov 16, 2004
- 512 views
- Last edited Nov 17, 2004
Brian Broker wrote: > > Jonas Temple wrote: > > > > Pete wrote: > > > Tried again after applying patch (I think it was already applied, but > > > did it again..) still fails - worth a try tho. > > > > > > Pete > > > > > Pete, > > > > I have Win32Lib v0.60.6 and this works for me. I reworked your program > > and this works on this WinXP Pro machine: > > > <snip> > > That still didn't work for me but it does work when I cut out support > for RichEdit 5.0. You can check to see what version you are actually > using by checking the value of WC_RICHEDIT. Anyway, when I edited > w32dll.ew as follows, it worked fine: > }}} <eucode> > global constant > riched32 = > > registerw32Library({"riched20.dll","riched32.dll"}),--{"Msftedit.dll","riched20.dll","riched32.dll"}), > > -- Rich Edit control > WC_RICHEDIT10 = "RICHEDIT", > WC_RICHEDIT20 = "RichEdit20A"--, > --WC_RICHEDIT50 = "RICHEDIT50W" > global sequence WC_RICHEDIT > > vw32Libraries[riched32][1] = linkDLL(vw32Libraries[riched32][2]) > if vw32Libraries[riched32][1][1] = 1 then > WC_RICHEDIT = WC_RICHEDIT20--WC_RICHEDIT = WC_RICHEDIT50 > > elsif vw32Libraries[riched32][1][1] = 2 then > WC_RICHEDIT = WC_RICHEDIT10--WC_RICHEDIT = WC_RICHEDIT20 > > else > WC_RICHEDIT = WC_RICHEDIT10 > end if > </eucode> {{{ > Maybe the lib shouldn't try supporting RichEdit 5.0 until we need some > particular feature of 5.0. > > -- Brian > Thanks Brian, that made it work, looks like it was using the RICHEDIT50W (or RichEdit 4.1..), strange that for Jonas using XP Pro it seemed to work whereas XP Home failed... Pete
8. RE: RichEdit and findText
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 16, 2004
- 543 views
- Last edited Nov 17, 2004
Pete wrote: > > Brian Broker wrote: > > > > Jonas Temple wrote: > > > > > > Pete wrote: > > > > Tried again after applying patch (I think it was already applied, but > > > > > > > > did it again..) still fails - worth a try tho. > > > > > > > > Pete > > > > > > > Pete, > > > > > > I have Win32Lib v0.60.6 and this works for me. I reworked your program > > > and this works on this WinXP Pro machine: > > > > > <snip> > > > > That still didn't work for me but it does work when I cut out support > > for RichEdit 5.0. You can check to see what version you are actually > > using by checking the value of WC_RICHEDIT. Anyway, when I edited > > w32dll.ew as follows, it worked fine: > > }}} <eucode> > > global constant > > riched32 = > > > > registerw32Library({"riched20.dll","riched32.dll"}),--{"Msftedit.dll","riched20.dll","riched32.dll"}), > > > > -- Rich Edit control > > WC_RICHEDIT10 = "RICHEDIT", > > WC_RICHEDIT20 = "RichEdit20A"--, > > --WC_RICHEDIT50 = "RICHEDIT50W" > > global sequence WC_RICHEDIT > > > > vw32Libraries[riched32][1] = linkDLL(vw32Libraries[riched32][2]) > > if vw32Libraries[riched32][1][1] = 1 then > > WC_RICHEDIT = WC_RICHEDIT20--WC_RICHEDIT = WC_RICHEDIT50 > > > > elsif vw32Libraries[riched32][1][1] = 2 then > > WC_RICHEDIT = WC_RICHEDIT10--WC_RICHEDIT = WC_RICHEDIT20 > > > > else > > WC_RICHEDIT = WC_RICHEDIT10 > > end if > > </eucode> {{{ > > Maybe the lib shouldn't try supporting RichEdit 5.0 until we need some > > particular feature of 5.0. > > > > -- Brian > > > Thanks Brian, that made it work, looks like it was using the RICHEDIT50W > (or RichEdit 4.1..), strange that for Jonas using XP Pro it seemed to work > whereas XP Home failed... I suggest that Jonas is not actually using Rich Edit 4.1. That version seems to only support Unicode utf-16 encoding and thus win32lib will need to cater for that. I've now got getSelectedText() and findText() working for utf16 but I need to check out some other routines as well. -- Derek Parnell Melbourne, Australia
9. RE: RichEdit and findText
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Nov 17, 2004
- 541 views
Derek Parnell wrote: > > I suggest that Jonas is not actually using Rich Edit 4.1. That version > seems to only support Unicode utf-16 encoding and thus win32lib > will need to cater for that. I've now got getSelectedText() and > findText() working for utf16 but I need to check out some other > routines as well. > Take a look at: MultiByteToWideChar WideCharToMultiByte I use them in unicode.ew included with EuCOM (COM uses all unicode strings). Matt Lewis