Archived

This topic is now archived and is closed to further replies.

SendMessage i18n question

This topic is 4948 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What format (ANSI or UNICODE) should the string be in for messages which take a string parameter (eg EM_SETSEL)? Is there a way to force a particular format (similar to how SetWindowTextA will call the ansi version)? [edited by - ugenn on May 29, 2004 7:39:47 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by ugenn
What format (ANSI or UNICODE) should the string be in for messages which take a string parameter (eg EM_SETSEL)? Is there a way to force a particular format (similar to how SetWindowTextA will call the ansi version)?

[edited by - ugenn on May 29, 2004 7:39:47 AM]


Nevermind. Got it. *Slaps forehead. stupid*

Share this post


Link to post
Share on other sites
EM_SETSEL is a bad example: it doesn''t take a string parameter.

In any case, assuming you''re interested primarily in RichEdit controls, since you mentioned EM_SETSEL, RichEdit controls since version 2.0 come in both narrow and wide character versions. For example, a RichEdit 2.0 control can be created in with either the RichEdit20A or RichEdit20W windows classes. If you create the RichEdit control in the ANSI version, then all messages accepted by the control are expected to contain pointers to ANSI strings. If you create a RichEdit control in Unicode, then all messages accepted by the control are expected to contain pointers to wide character strings.

Share this post


Link to post
Share on other sites
quote:
Original post by SiCrane
EM_SETSEL is a bad example: it doesn't take a string parameter.

In any case, assuming you're interested primarily in RichEdit controls, since you mentioned EM_SETSEL, RichEdit controls since version 2.0 come in both narrow and wide character versions. For example, a RichEdit 2.0 control can be created in with either the RichEdit20A or RichEdit20W windows classes. If you create the RichEdit control in the ANSI version, then all messages accepted by the control are expected to contain pointers to ANSI strings. If you create a RichEdit control in Unicode, then all messages accepted by the control are expected to contain pointers to wide character strings.


Was a typo. Meant EM_REPLACESEL. ANSI/UNICODE can be selected by explicitly using either SendMessageA/SendMessageW.

Not sure if what you say is right. Does it matter how the control is created? Was always under the impression that ANSI or UNICODE is determined by the 'A' or 'W' versions.

[edited by - ugenn on May 29, 2004 9:10:23 AM]

Share this post


Link to post
Share on other sites
Read the RichEdit control documentation. I''ll quote from MSDN:

In Rich Edit 2.0, if you create a Unicode rich edit control (one that expects Unicode text messages), you must specify only Unicode data in any window messages sent to the control. Similarly, if you create an ANSI rich edit control, send only ANSI or double-byte character set (DBCS) data. You can use the IsWindowUnicode function to determine whether a rich edit control uses Unicode text messages. Note that the rich edit COM interfaces use Unicode text unless they encounter a code page argument.

Share this post


Link to post
Share on other sites
quote:
Original post by SiCrane
Read the RichEdit control documentation. I''ll quote from MSDN:

In Rich Edit 2.0, if you create a Unicode rich edit control (one that expects Unicode text messages), you must specify only Unicode data in any window messages sent to the control. Similarly, if you create an ANSI rich edit control, send only ANSI or double-byte character set (DBCS) data. You can use the IsWindowUnicode function to determine whether a rich edit control uses Unicode text messages. Note that the rich edit COM interfaces use Unicode text unless they encounter a code page argument.




Yes, I misread the earlier post. I meant controls in general, not Riched specifically.

Share this post


Link to post
Share on other sites