Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi,

i am designing a windows application for tablet pc using vb.net 2.0.
On all my forms i want A-Z and 0-9 keys on the form itself.
On press of any of these keys user would be able to type anywhere where there is a cursor.
The problem is if i press the button the focus shifts to the button and thus losing the cursor from the input control.
Can anybody tell how can I make my buttons focusless so that the cursor remains on the input control?
Also if there is any other approach i can use.
I am not supposed to use the virtual keyboard.

regards,
gopal
Posted

I answered similar questions several times, please see this:

Application focus getting and losing[^]
Programming on BACKSPACE button[^]

Sorry, the first Question is in C#, but if you want to get good help and code sample and you do .NET development without some understanding of C# you won't get much help anyway.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 8-Mar-11 15:16pm    
Yepp, my 5, by using WS_EX_NOACTIVATE you avoid a lot of thorny issues, and keeping the window on top is also more or less required - good links :)
Sergey Alexandrovich Kryukov 8-Mar-11 15:24pm    
Thank you. In fact, both things are required in practice.
--SA
Here is an article Touchscreen Keyboard UserControl[^]

There is also another alternative:
How to show, close, move or resize the On-Screen Keyboard[^] - if you are using a tablet, this shows how to interact with the windows wirtual keyboard ...

For more info on what's available with windows take a look at Tablet PC[^]

WM_SETFOCUS[^] - wParam contains the handle of the previous focused window.

Handling the event by overriding
VB
Protected Overridable Sub WndProc ( _
    ByRef m As Message _
)


for your control. This may be required since Control.GotFocus Event[^] does not include the handle to the previously focused window.

Regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 6-Mar-11 19:07pm    
Very good references and recommendations, my 5.
I still think my method also works well, based on minimalistic approaches and is well tested.
--SA
Espen Harlinn 8-Mar-11 11:48am    
Thanks SAKryukov - I'm not 100% sure the input from the virtual keyboard ends up at the right input position as it may be that the only really solution is to write a device driver for delivering keyboard input to the target application, and use hooks to keep track of the window that is to recieve the input - at least if it is to work with all applications. sending WM_KEY_XXX may not be good enough
Sergey Alexandrovich Kryukov 8-Mar-11 14:12pm    
Actually, if you look at my answer you will see how all the problems can be addressed. I happened to implement a good Virtual keyboard component (around 2006); this is not very trivial.
--SA
well guys thanx for all ur support...
my application is live now....
however the solution to my problem was quite simple...

Instead of buttons, i used labels and on the click of that label i used sendkeys.

Regards
gopal
 
Share this answer
 
v2

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