RE: RichEdit and findText
- Posted by Jonas Temple <jtemple at yhti.net> Nov 16, 2004
- 519 views
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