Article View: borland.public.cppbuilder.nativeapi
Article #2129Storing UNICODE in mixed string resource
From: Mike Collins
Date: Tue, 10 Apr 2007 10:07
Date: Tue, 10 Apr 2007 10:07
54 lines
3285 bytes
3285 bytes
Hi all, hope everyone had a good Easter break.
Got an on running problem and still having issues resolving it. I posted a
few months back but didn't seem to resolve the issue. The background to the
problem is that i HAVE to identify an dialog by it's caption. We have a
convoluted system which is too far down the development path to change. The
system needs to close a particular dialog box created by a MS dll. The
Windows class name is not sufficient to identify the dialog (#32770) and so
I have to enumerate all windows looking for a particular caption. This
system works fine until the software is deployed on non-English platforms,
where the caption changes according to the language being used. After
searching MSDN, we have found that there are approximately 26 core languages
that are supported by MS and which cause the caption to change. So far, we
have got all of the roman-based ANSI versions and copied there captions into
a resource file. The software basically gets the system local and then
looks up the corrisponding caption for comparission. Again, this works
fine, our enum call-back looks like this:
BOOL CALLBACK Main::EnumWinProc(HWND hWnd, long lParam)
{
char cCaption[255], cClassID[255];
GetWindowText(hWnd, cCaption, sizeof(&cCaption));
GetClassName(hWnd, cClassID, sizeof(&cClassID));
AnsiString sStoredCaption;
// Load caption from string table resource based on system local
if ((strcmp(cClassID, "#32770")==0)
&&(strcmp(cCaption, sStoredCaption.c_str())==0))
{
PostMessage(hWnd, WM_CLOSE, 0, 0);
return FALSE;
}
else
return TRUE;
}
The problem that I'm having now is dealing with platforms that use
non-roman, Unicode strings i.e. Hebrew and Russian. On these systems, i can
get the caption but i seem unable to store it in my string table along side
the other ANSI captions (I get a resource compile error).
My first question is, how can i store these string in my string resource?
Do i need to convert them to escape characters first?
My second question is, how do i modify the above call-back so that it can
work with either UNI or ANSI without having to compile separate versions -
I'm trying to make something generic that will work seamlessly on both
platforms.
I hope this makes sense,
Many thanks in advance,
Mike Collins
Technical Details
Message-ID:
<461b4e2f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4f9f4ee974b60660,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mike Collins" <its@TheBottomOfThePost> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Storing UNICODE in mixed string resource Date: Tue, 10 Apr 2007 10:07:59 -0000 Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.3959 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.3959 NNTP-Posting-Host: 89.242.71.42 Message-ID: <461b4e2f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1176194607 89.242.71.42 (10 Apr 2007 01:43:27 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail