1. Problem with findText (win32lib v0.60.6)

I tested the following innocuous program on WinXP home SP1:
include win32lib.ew
constant 
w=create(Window,"Test",0,100,100,100,100,0),
r=create(RichEdit,"tadarzadarmi",w,10,10,50,50,0),
b=create(PushButton,"push",w,60,10,40,20,0)

procedure x(integer id,integer event,sequence p)
puts(1,"findText(r,\"adar\",{1,24},0)"&'\n)
?findText(r,"adar",{1,24},0)
setIndex(r,{4,10})
?getSelectedText(r)
end procedure
setHandler(b,w32HClick,routine_id("x"))

WinMain(w,Normal)


Everything displays fine. WC_RICHEDIT reads "RICHED50".
Pushing the button produces the following output:
findText(r,"adar",{1,24},0)
0
{97,0,114,0,122,0}


 From what getSelectedText() returns, it looks like the text is 
stored using 16-bit characters somewhere.

Does anyone has an idea how to fix this? I bet the trick is changing the 
way the string is stored in the FINDTEXTEX structure. However, I tried 
replacing "adar" with {97,0,100,0,97,0,114,0}, and that wasn't any better.

Thanks in advance.

CChris

new topic     » topic index » view message » categorize

2. Re: Problem with findText (win32lib v0.60.6)

CChris wrote:

> I tested the following innocuous program on WinXP home SP1:
> }}}
<eucode>
> include win32lib.ew
> constant 
> w=create(Window,"Test",0,100,100,100,100,0),
> r=create(RichEdit,"tadarzadarmi",w,10,10,50,50,0),
> b=create(PushButton,"push",w,60,10,40,20,0)
> 
> procedure x(integer id,integer event,sequence p)
> puts(1,"findText(r,\"adar\",{1,24},0)"&'\n)
> ?findText(r,"adar",{1,24},0)
> setIndex(r,{4,10})
> ?getSelectedText(r)
> end procedure
> setHandler(b,w32HClick,routine_id("x"))
> 
> WinMain(w,Normal)
> </eucode>
{{{

> 
> Everything displays fine. WC_RICHEDIT reads "RICHED50".
> Pushing the button produces the following output:
> }}}
<eucode>
> findText(r,"adar",{1,24},0)
> 0
> {97,0,114,0,122,0}
> </eucode>
{{{

> 
>  From what getSelectedText() returns, it looks like the text is 
> stored using 16-bit characters somewhere.
> 
> Does anyone has an idea how to fix this? I bet the trick is changing the 
> way the string is stored in the FINDTEXTEX structure. However, I tried 
> replacing "adar" with {97,0,100,0,97,0,114,0}, and that wasn't any better.



If running on WinXP SR1 or later, Rich Edit 4.1 class, using 
Msftedit.dll, expects strings *in Unicode*.

The following code will fix the problem for you. The string you want to 
find is -to_find-

<EUCODE>
sequence to_find, to_find2
if equal(WC_RICHEDIT,"RICHEDIT50W") then
     -- Change search string to 'pseudo Unicode'
     to_find2 = to_find
     to_find = {}
     for i = 1 to length(to_find2) do
         to_find = to_find & to_find[i] & #00
     end for
end if
</EUCODE>


This recently caused a bug in ViewCodeBase.ew (part of IDE), and I wrote 
the fix above for that.

Derek Parnell is aware of this issue, and I expect it will be addressed 
in a future win32lib.

-- 
Craig

new topic     » goto parent     » topic index » view message » categorize

3. Re: Problem with findText (win32lib v0.60.6)

Craig Welch wrote:

> Derek Parnell is aware of this issue, and I expect it will be addressed 
> in a future win32lib.

Thanks Craig. Yes it is a problem but it's more complex than that too. I need to
also get the library to handle getText returning UTF16 data (wide characters).
And the bigger issue of wide character support for all the other API routines
that can use it.

-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu