RolandAZ
asked on
Using unicode strings in Comboxboxex with Win32 API C problem
Hello again, Experts!
I have a problem with the comboboxex using C Win32 API.
The comboboxex contains unicode strings (Chinese, Thai,Japanese,etc.)
Whenever I send CB_SELECTSTRING or CB_FINDSTRING to the comboboxex window with a unicode
string I get the index found as zero, even though there is a matching first character in the listbox(of the comboboxex).
Using a WCHAR buffer as destination, the strings extracted from the listbox(of comboboxex) with CB_GETSTRING are non-unicode!! Though the comboboxex displays the strings in its listbox as unicode!
Sending a CBEM_SETUNICODEFORMAT does nothing.
/////////////////
Example:
comboboxex listbox: (xxx denotes non-English characters)
---
Chinese xxx
Japanese xxx
...
----
unicode string to find: "C"
-----------------
CB_SELECTSTRING/CB_FINDSTR ING returns 0!!!
with WCHAR destination buffer, CB_GETLBTEXT returns non-unicode strings! The non-English characters become ??? in memory.
/////////////////
Are there preliminary steps needed before CB_SELECTSTRING/CB_FINDSTR ING so that the comboboxex will return the right index?
Are there preliminary steps needed before CB_GETLBTEXT so that the comboboxex will return Unicode strings?
If so, what are they?
Any help / tips/ code are appreciated!! Thanks in advance!
Roland
I have a problem with the comboboxex using C Win32 API.
The comboboxex contains unicode strings (Chinese, Thai,Japanese,etc.)
Whenever I send CB_SELECTSTRING or CB_FINDSTRING to the comboboxex window with a unicode
string I get the index found as zero, even though there is a matching first character in the listbox(of the comboboxex).
Using a WCHAR buffer as destination, the strings extracted from the listbox(of comboboxex) with CB_GETSTRING are non-unicode!! Though the comboboxex displays the strings in its listbox as unicode!
Sending a CBEM_SETUNICODEFORMAT does nothing.
/////////////////
Example:
comboboxex listbox: (xxx denotes non-English characters)
---
Chinese xxx
Japanese xxx
...
----
unicode string to find: "C"
-----------------
CB_SELECTSTRING/CB_FINDSTR
with WCHAR destination buffer, CB_GETLBTEXT returns non-unicode strings! The non-English characters become ??? in memory.
/////////////////
Are there preliminary steps needed before CB_SELECTSTRING/CB_FINDSTR
Are there preliminary steps needed before CB_GETLBTEXT so that the comboboxex will return Unicode strings?
If so, what are they?
Any help / tips/ code are appreciated!! Thanks in advance!
Roland
If you are using NT,2000 or XP
try calling SendMessageW instead of SendMessage - see if that helps.
try calling SendMessageW instead of SendMessage - see if that helps.
ASKER
jkr, GGUNDY,
Thanks for tips!
jkr,
it never returned CB_ERR, even if there is no matching string. :)
GGUNDY,
I'm using SendMessageW, but the CB_SELECTSTRING/CB_FINDSTR ING/CB_GET STRING still sees the strings as non-unicode.
--------------
I made a workaround by not using CB_SELECTSTRING/CB_FINDSTR ING, but used CB_GETSTRING and MultiByteToWideChar the returned strings, and compared each one from the string to be searched.
But wish I could use the CB_SELECTSTRING/CB_FINDSTR ING/CB_GET STRING to work returned automatic unicode strings, though.
Thanks again , guys.
Roland
Thanks for tips!
jkr,
it never returned CB_ERR, even if there is no matching string. :)
GGUNDY,
I'm using SendMessageW, but the CB_SELECTSTRING/CB_FINDSTR
--------------
I made a workaround by not using CB_SELECTSTRING/CB_FINDSTR
But wish I could use the CB_SELECTSTRING/CB_FINDSTR
Thanks again , guys.
Roland
Have you had a look at CBEM_SETUNICODEFORMAT?
ASKER
Yechezkel,
Yup! But CBEM_SETUNICODEFORMAT doesn't seem to affect it.
Roland
P.S. CB_GETSTRING (in above comment) is macro for CB_GETLBTEXT
Yup! But CBEM_SETUNICODEFORMAT doesn't seem to affect it.
Roland
P.S. CB_GETSTRING (in above comment) is macro for CB_GETLBTEXT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually, that's the correct behaviour/result when the string to find is at the 1st position (resembling index 0) - if nothing was found, you'd get CB_ERR, which is -1.