1. Win32Lib and Unicode

Hi Guys,
I've got a nice routine to convert UTF-8 into "Windows" unicode (adapted from
routines by Tommy Carlier) along with a modified wPuts to write the unicode to my
window. That bit is working fine but now to complete the jigsaw I need a unicode
version of setHint and at the moment I can't see an easy way to do it, can anyone
help?

Regards PeteS

new topic     » topic index » view message » categorize

2. Re: Win32Lib and Unicode

Pete Stoner wrote:
> 
> Hi Guys,
> I've got a nice routine to convert UTF-8 into "Windows" unicode (adapted from
> routines by Tommy Carlier) along with a modified wPuts to write the unicode
> to my window. That bit is working fine but now to complete the jigsaw I need
> a unicode version of setHint and at the moment I can't see an easy way to do
> it, can anyone help?
> 
> Regards PeteS

Simply use setHint[Ex]() and pass a routine_id as spelled out in the docs. The
routine will return an Euphoria sequence representing your 16-bit encoded text,
like {'H',0,'e',0,'l',0,'l',0,'o',0,0}.
Note the extra zero at the end, because w32store() will add only one and 16-bit
strings need 2 of them. So the char #ABCD would be coded as #CD,#AB.
Also, make sure the tooltip font supports the characters you are going to
display. You may need to call setHintFont() for this purpose.
I didn't test this, but I'd be confident, if only because there are no special
Unicode tooltip messages in the API.

HTH
CChris

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

3. Re: Win32Lib and Unicode

Pete Stoner wrote:
> 
> Hi Guys,
> I've got a nice routine to convert UTF-8 into "Windows" unicode (adapted from
> routines by Tommy Carlier) along with a modified wPuts to write the unicode
> to my window. That bit is working fine but now to complete the jigsaw I need
> a unicode version of setHint and at the moment I can't see an easy way to do
> it, can anyone help?

You could use wxEuphoria, which supports unicode.

Matt

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

4. Re: Win32Lib and Unicode

CChris wrote:
> 
> Pete Stoner wrote:
> > 
> > Hi Guys,
> > I've got a nice routine to convert UTF-8 into "Windows" unicode (adapted
> > from
> > routines by Tommy Carlier) along with a modified wPuts to write the unicode
> > to my window. That bit is working fine but now to complete the jigsaw I need
> > a unicode version of setHint and at the moment I can't see an easy way to do
> > it, can anyone help?
> > 
> > Regards PeteS
> 
> Simply use setHint[Ex]() and pass a routine_id as spelled out in the docs. The
> routine will return an Euphoria sequence representing your 16-bit encoded
> text,
> like {'H',0,'e',0,'l',0,'l',0,'o',0,0}.
> Note the extra zero at the end, because w32store() will add only one and
> 16-bit
> strings need 2 of them. So the char #ABCD would be coded as #CD,#AB.
> Also, make sure the tooltip font supports the characters you are going to
> display.
> You may need to call setHintFont() for this purpose.
> I didn't test this, but I'd be confident, if only because there are no special
> Unicode tooltip messages in the API.
> 
> HTH
> CChris

I'm sorry to say this but I don't think that will work. The setHint() procedure
does not work in isolation but requires a ToolTip control. As with any windows
control that deals with text strings, the ToolTip control comes in both ANSI and
INICODE versions. The ToolTip control provided by Win32Lib is the ANSI version.

Some controls can be put in unicode mode after creation but the ToolTip control
is not one of them. You must create your own unicode version of the ToolTip
control. The Win32Lib create() function is of no help here as it only creates
ANSI controls. You would have to define and call CreateWindowW() to do this,
passing only unicode strings.

Next you would have to write a unicode version of SetHint() which will
communicate with the new tooltip control. Some controls have unicode specific
messages, most do not. A unicode ToolTip control requires that you send messages
to it with SendMessageW(). In this case you would create a TOOLTIP structure
which contains the desired text ( in Unicode) and send it to the ToolTip control
using SendMessageW().

I have worked quite a bit with other Unicode controls but never had the need to
do this with the ToolTip control.

Larry Miller

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

5. Re: Win32Lib and Unicode

CChris wrote:
> 
> Pete Stoner wrote:
> > 
> > Hi Guys,
> > I've got a nice routine to convert UTF-8 into "Windows" unicode (adapted
> > from
> > routines by Tommy Carlier) along with a modified wPuts to write the unicode
> > to my window. That bit is working fine but now to complete the jigsaw I need
> > a unicode version of setHint and at the moment I can't see an easy way to do
> > it, can anyone help?
> > 
> > Regards PeteS
> 
> Simply use setHint[Ex]() and pass a routine_id as spelled out in the docs. The
> routine will return an Euphoria sequence representing your 16-bit encoded
> text,
> like {'H',0,'e',0,'l',0,'l',0,'o',0,0}.
> Note the extra zero at the end, because w32store() will add only one and
> 16-bit
> strings need 2 of them. So the char #ABCD would be coded as #CD,#AB.
> Also, make sure the tooltip font supports the characters you are going to
> display.
> You may need to call setHintFont() for this purpose.
> I didn't test this, but I'd be confident, if only because there are no special
> Unicode tooltip messages in the API.
> 
> HTH
> CChris

Hi Chris,
I don't see any mention of passing a routine_id in the docs for setHintEx
(looked in version 0.70.4), since presumably the routine would just return the
encoded text as you mention I just tried doing...
setHintEx(win, {'H',0,'e',0,'l',0,'l',0,'o',0,0}, TTF_DI_SETITEM )
but this just displays an "H" not the full string (note the TTF_DI_SETITEM flag
is purely random as it was not needed and didn't make any difference)?

Matt, I would like to try using WxWindows but the app is too heavily tied into
win32lib and would be too much work for a wx novice to start translating it..

PeteS

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

6. Re: Win32Lib and Unicode

Pete Stoner wrote:
> 
> CChris wrote:
> > 
> > Pete Stoner wrote:
> > > 
> > > Hi Guys,
> > > I've got a nice routine to convert UTF-8 into "Windows" unicode (adapted
> > > from
> > > routines by Tommy Carlier) along with a modified wPuts to write the
> > > unicode
> > > to my window. That bit is working fine but now to complete the jigsaw I
> > > need
> > > a unicode version of setHint and at the moment I can't see an easy way to
> > > do
> > > it, can anyone help?
> > > 
> > > Regards PeteS
> > 
> > Simply use setHint[Ex]() and pass a routine_id as spelled out in the docs.
> > The
> > routine will return an Euphoria sequence representing your 16-bit encoded
> > text,
> > like {'H',0,'e',0,'l',0,'l',0,'o',0,0}.
> > Note the extra zero at the end, because w32store() will add only one and
> > 16-bit
> > strings need 2 of them. So the char #ABCD would be coded as #CD,#AB.
> > Also, make sure the tooltip font supports the characters you are going to
> > display.
> > You may need to call setHintFont() for this purpose.
> > I didn't test this, but I'd be confident, if only because there are no
> > special
> > Unicode tooltip messages in the API.
> > 
> > HTH
> > CChris
> 
> Hi Chris,
> I don't see any mention of passing a routine_id in the docs for setHintEx
> (looked
> in version 0.70.4), since presumably the routine would just return the encoded
> text as you mention I just tried doing... 
> setHintEx(win, {'H',0,'e',0,'l',0,'l',0,'o',0,0}, TTF_DI_SETITEM )
> but this just displays an "H" not the full string (note the TTF_DI_SETITEM
> flag
> is purely random as it was not needed and didn't make any difference)?
> 
> Matt, I would like to try using WxWindows but the app is too heavily tied into
> win32lib and would be too much work for a wx novice to start translating it..
> 
> PeteS

This expectedly doesn't work, as an ANSI string is expected when you pass some
text.

Here is the relevant doc part for setHint() about passing a routine_id.
setHintEx() is no different:
<quote>
-- It is possible to dynamically set the text of a tooltip so that each time
-- the control needs to display a tip, it first calls a routine of your own
-- that must supply the text to display. To do this, set the /i text parameter
-- to the routine_id of your function. Your /b function will receive two
parameters:
-- ( id, width ) where /i id is the control that needs a tip, and /i width is
the
-- width of the tooltip box that will be used (in pixels). Your function must
-- return a /b sequence. That sequence can simply be the tip text, or a
2-element
-- sequence in the form { tiptext, newwidth }.
</quote>

If your tooltip control can handle 16-bit strings, you are done. Otherwise,
we'll have to go Larry's route, and this won't be on the next release I'm afraid.

CChris

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

7. Re: Win32Lib and Unicode

CChris wrote:
> 
> If your tooltip control can handle 16-bit strings, you are done. Otherwise,
> we'll have to go Larry's route, and this won't be on the next release I'm
> afraid.

Yes, I'd looked at possibly doing this previously.  You'd need to change all 
of the dll imports from using the ansi to using the wide versions (i.e., 
CreateWindowA vs CreateWindowW).  Plus you'd have to do the string conversions
every time the user passed a string to the library.  It's a lot of work.

Matt

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

8. Re: Win32Lib and Unicode

Matt Lewis wrote:
> 
> CChris wrote:
> > 
> > If your tooltip control can handle 16-bit strings, you are done. Otherwise,
> > we'll have to go Larry's route, and this won't be on the next release I'm
> > afraid.
> 
> Yes, I'd looked at possibly doing this previously.  You'd need to change all
> 
> of the dll imports from using the ansi to using the wide versions (i.e., 
> CreateWindowA vs CreateWindowW).  Plus you'd have to do the string conversions
> every time the user passed a string to the library.  It's a lot of work.
> 
> Matt

OK Chris and Matt, thanks for looking at this, I think I'm gonna settle for what
I've got. I've found that the existing tooltip displays the correct character
from the UFT-8 conversion up to unicode #FF, #00 by just passing the first byte.
That covers most of the characters I need and since the wPutsW works fine for all
the unicode I'll stick with that for now..

Thanks PeteS

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

9. Re: Win32Lib and Unicode

This is a call for codevelopers and/or testers.

THere are two areas where win32lib probably needs too improve: Unicode support
and Vista-specific features.

Since I don't have a Unicode build of Windows on my machine, and don't have
Vista, I can hardly:
* have a precise idea of the needs;
* code anything I can test. I can always write something according to my
understanding of the docs, but such code works out of the box less often than
not.

For this reason, some cooperation is probably useful.

I plan to release 70.4 next weekend, and 70.5 during the w2008-09 winter. In the
meantime, if anyone is interested, then we can arrange how to work together.

I'm always glad to take contributed code in, whatever the area is.

CChris

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

Search



Quick Links

User menu

Not signed in.

Misc Menu