Solved

Using unicode strings in Comboxboxex  with  Win32 API C  problem

Posted on 2002-05-08
8
1,019 Views
Last Modified: 2013-12-03
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_FINDSTRING 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_FINDSTRING 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
0
Comment
Question by:RolandAZ
8 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6997262
>>I get the index found as zero

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.
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6997651
If you are using NT,2000 or XP
try calling SendMessageW instead of SendMessage - see if that helps.
0
 
LVL 1

Author Comment

by:RolandAZ
ID: 6998561
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_FINDSTRING/CB_GETSTRING still sees the strings as non-unicode.

--------------
I made a workaround by not using CB_SELECTSTRING/CB_FINDSTRING, 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_FINDSTRING/CB_GETSTRING to work returned automatic unicode strings, though.


Thanks again , guys.
Roland



0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Expert Comment

by:Yechezkel
ID: 6998856
Have you had a look at CBEM_SETUNICODEFORMAT?
0
 
LVL 1

Author Comment

by:RolandAZ
ID: 6998921
Yechezkel,
Yup! But CBEM_SETUNICODEFORMAT doesn't seem to affect it.

Roland
P.S. CB_GETSTRING (in above comment) is macro for  CB_GETLBTEXT

0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 10743301
PAQed, with points refunded (200)

CetusMOD
Community Support Moderator
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Fox Pro commands 15 48
Average count of individuals by year(s) and month(s) selected 4 40
VBA Error Since Excel 2016 x64 5 114
Problem to file 3 76
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question