473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

IME mode convert

I'm wrinting a program that is Japanese on screen keyboard. When I use the ImmSetOpenStatus function to open IME for the focus windows as MS words... But it have been always failed. This is my code:
Expand|Select|Wrap|Line Numbers
  1. BOOL COnscreenKeyboardDlg::SetImeSwitchON() 
  2. {
  3.     m_fLog.initLogFile();
  4.     HWND wnd = ::GetForegroundWindow();
  5.     if(IsWindow(wnd))
  6.     {
  7.         if(!AttachThreadInput(GetWindowThreadProcessId(m_hWnd,NULL),GetWindowThreadProcessId(wnd,NULL),TRUE)){
  8.             m_fLog.putToLogFile( __FILE__, __LINE__, "AttachThreadInput failed\n");
  9.         }
  10.         ::SetFocus(wnd);
  11.         char cWindowsName[MAX_PATH];
  12.         ::GetWindowText(wnd,cWindowsName,MAX_PATH);
  13.         m_fLog.putToLogFile( __FILE__, __LINE__, cWindowsName);
  14.         HIMC hIMC = ImmGetContext(wnd);
  15.         if(!ImmGetOpenStatus(hIMC)){
  16.             if(!ImmSetOpenStatus(hIMC, TRUE)){
  17.                 m_fLog.putToLogFile( __FILE__, __LINE__, "ImmSetOpenStatus failed\n");
  18.             }else{
  19.                 m_fLog.putToLogFile( __FILE__, __LINE__, "ImmSetOpenStatus successed\n");
  20.             }
  21.         }    
  22.         ImmReleaseContext( wnd, hIMC);
  23.     }else{
  24.         m_fLog.putToLogFile( __FILE__, __LINE__, "IsWindow(wnd) failed\n");
  25.     }
  26.     m_fLog.closeLogFile();
  27.     return 0;
  28. }
  29.  
I dont know where is wrong. please help me.
Apr 5 '10 #1

✓ answered by weaknessforcats

HIMC hIMC = ImmGetContext(wnd);
Does ImmGetContext return a non-null HIMC? You don't check.

10 5018
weaknessforcats
9,208 Expert Mod 8TB
You are not checking any return values to se if things are working.

Hev you stepped though this with your debugger?
Apr 5 '10 #2
Hi weaknessforcats,
Thank you for your answer.
Yes I have debugged step by step and put it to the log file. It always failed at the ImmSetOpenStatus function.
Apr 6 '10 #3
weaknessforcats
9,208 Expert Mod 8TB
HIMC hIMC = ImmGetContext(wnd);
Does ImmGetContext return a non-null HIMC? You don't check.
Apr 6 '10 #4
Hi weaknessforcats,
Thank you for your show. really, HIMC hIMC = ImmGetContext(wnd); was return NULL. But wnd is not NULL. why it return NULL? Can you teach me to correct it?
Apr 7 '10 #5
weaknessforcats
9,208 Expert Mod 8TB
Are you using a version of Windows that supports this feature?
Apr 7 '10 #6
yes, I'm using Windows XP japanese version. It is supporting IME.
Apr 8 '10 #7
weaknessforcats
9,208 Expert Mod 8TB
If your HWND is valid and you still get a NULL HIMC then you have a question for Microsoft.
Apr 8 '10 #8
Hi weaknessforcats,
Thank you for your help. I have solved it.
Apr 9 '10 #9
weaknessforcats
9,208 Expert Mod 8TB
I'm glad to here that. But I am curious as to what the problem was. Can you share your solution?
Apr 9 '10 #10
Hi weaknessforcats,
The problem was my application can not switch IME mode of another application. So that ImmGetContext(wnd) always return null.
My solution is create global keyboard hook and implement the IME API in it. That's all.
Apr 10 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Guyon Morée | last post by:
what is the difference? if I open a text file in binary (rb) mode, it doesn't matter... the read() output is the same.
9
by: GRoll21 | last post by:
I have a program here that asks the number of students surveyed. then it will ask how many movies each student has watched. After thats been collected it does functions to find the average, median,...
0
by: Edward Diener | last post by:
I have some questions about the instructions for creating a mixed mode DLL in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode" in the...
9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
0
by: Mike | last post by:
Hi, I am having problems with my program, the problem is it will not put the datagrid into edit mode. The .aspx page has the following code in it : - <asp:datagrid id="DataGrid2"...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
7
by: smith4894 | last post by:
Hello all, I'm working on writing my own streambuf classes (to use in my custom ostream/isteam classes that will handle reading/writing data to a mmap'd file). When reading from the mmap...
1
by: Sathyaish | last post by:
I have the following scenario: Algorithm: 3DES Cipher Mode: CBC Key Size: 128-bit Block Size: 64 bit IV: 0x0000000000000000 (an eight byte array of zeros) The results I get using .NET with...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
8
by: Lucas | last post by:
I need print a file in binary mode . f = f.open('python.jpg','rb') bytes = f.read() f.close() print(bytes) I can't get any binary code.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.