Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to create a virtual keyboard using MFC.
i am a newbie and have no clue as to how i should start.
Posted

There are two keys points here, if you want the real Virtual Keyboard which would work system-wide.

For emulation of keyboard input, use Windows API SendInput, see http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[^].

Now the big problem is that you need to have a keyboard focus on the control where you "type" data. It will create a problem for the Virtual Keyboard window, as it will grab focus on each click. To overcome this problem, you need two things: the Virtual Keyboard window should not be able to activate. At the same time, it should be on top. So, you need two unusual styles: WS_EX_NOACTIVATE | WS_EX_TOPMOST.

To set the style during run time, you will need to call SetWindowLong, second parameter must be GWL_EXSTYLE. See http://msdn.microsoft.com/en-us/library/ms633591%28v=vs.85%29.aspx[^].

—SA
 
Share this answer
 
v2
Comments
Kim Togo 28-Jul-11 2:28am    
Good answer. My 5.
Sergey Alexandrovich Kryukov 28-Jul-11 2:44am    
Thank you, Kim.
--SA
Wonde Tadesse 30-Jul-11 17:41pm    
Excellent answer
Sergey Alexandrovich Kryukov 1-Aug-11 0:01am    
Thank you, Wonde.
--SA
There is a same question on CP with solution.
Take a look there-CP Question[^]
 
Share this answer
 
Comments
Member 8112150 26-Jul-11 7:18am    
do u know how i can do the message mapping for japanese characters?
RaviRanjanKr 28-Jul-11 6:03am    
sorry I've no any Ideas about it.
Kim Togo 28-Jul-11 2:29am    
Good link.
RaviRanjanKr 28-Jul-11 6:03am    
Thanks :)
 
Share this answer
 
Comments
Member 8112150 26-Jul-11 7:17am    
Thanks a lot.
the keyboard i need to create should be able to toggle languages.
do u know how i can do the message mapping for japanese characters?
Kim Togo 28-Jul-11 2:29am    
Good links.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900