Posted on 2005-05-03
Last Modified: 2013-12-03
I have a program named "A" supporting typing in my language . For example , If I type "a" then type "1" , it will become "á" .

a1  ---> á
a2  ---> à
a3  ---> ả
a4  ---> ã
a5  ---> ạ
o6  ---> ô

And I have a program in which I have a string = "a1" . Then I use

for (count=0; count<string.GetLength(); count++)
::PostMessage(hFocus, WM_KEYDOWN, VkKeyScan(string.GetAt(count)), 0);

The above program named A was already opened. But it just shows "a1" , not "á" . I want it shows "á" , not "a1" . How can I do ?
Question by:hahahahahaha
    LVL 86

    Expert Comment

    As is http:Q_21408834.html


    for (count=0; count<temp.GetLength(); count++)
    ::PostMessageW(hFocus, WM_KEYDOWN, VkKeyScanW(temp.GetAt(count)), 0);

    to enforce using the UNICODE version of the Win32 APIs. However, you'll have to ensure that 'temp' holds UNICODE data. E.g. ike in

    wchar_t wc = 0xa1;

    ::PostMessageW(hFocus, WM_KEYDOWN, VkKeyScanW(wc), 0);

    Author Comment

    Would you like to give me a program that can run ? I did like you but it didn't show anything . Ok , if I have a string = "ngu7o72i" , I want it will become "ng&#432;&#7901;i" when it shows on screen . I say again , I have string "ngu7o2i" , like this
    CString string = "ngu7o72i";

    for (count=0; count<string.GetLength(); count++)
    ::PostMessageW(hFocus, WM_KEYDOWN, VkKeyScanW(string.GetAt(count)), 0);

    It's still incorrect :(

    LVL 86

    Expert Comment

    Yes, the above is being fed with ANSI data. You need to use UNICODE:

    CString string = "ngu7o72i";
    wchar_t* pwsz = new wchar_t[string.GetLength() + 1];
    mbstowcs( pwsz, string, string.GetLength() + 1);

    for (count=0; count<string.GetLength(); count++)
    ::PostMessageW(hFocus, WM_KEYDOWN, VkKeyScanW(pwsz[count]), 0);

    delete [] pwsz;


    Author Comment

    It still shows ngu7o72i :( .

    Author Comment

    I cant understand what the difference between I type myself and I use "::PostMessage(hFocus, WM_KEYDOWN, VkKeyScan(string.GetAt(count)), 0); " .

    I think it is the same action . But the result is different :( .Plz help me , I'm hurry .
    LVL 86

    Accepted Solution

    >> It still shows ngu7o72i

    Yes. That's the same UNICODE representation. Unless you place e.g. Japanese characters in the source, you won't see a difference.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
    After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
    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.…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now