hackemall Posted December 22, 2003 Posted December 22, 2003 Hi there, I am trying to develop a virtual keyboard using vb.net. I used to forms, (one is real window, second one is keyboard window). When a label on keyboard is clicked, I make background window get the focus and then I use SendKeys method to press a button. This works fine. However, webbrowser control on main window doesn't get the focus. How can I create a virtaul keyboard that never gets focus like in W2K virtual keyboard. What is said is that "i subclassed the WM_MOUSEACTIVATE message in the form and passed the MA_NOACTIVATE message." on another form. How can this code be converted in vb.net code? Thanks for your answers!.... Quote
*Gurus* divil Posted December 22, 2003 *Gurus* Posted December 22, 2003 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = Win32.WM_MOUSEACTIVATE Then 'We don't want to be activated m.Result = New IntPtr(Win32.MA_NOACTIVATE) Return End If MyBase.WndProc(m) End Sub The value of WM_MOUSEACTIVATE is &H21 The value of MA_NOACTIVATE is 3 Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
hackemall Posted December 23, 2003 Author Posted December 23, 2003 Thank you divil. It works fine. It gets focus for just once, however afterwards, it loses its focus. Thank you for your help.... Quote
lef Posted March 8, 2004 Posted March 8, 2004 My window still looses focus I'm working with a On-Screen Keybord, just like the one in Accessebility in XP. I've made a form with topMost set to true. Also I've used your code to prevent my "on-screen keyboard form" getting the focus. Problem is that even if my window does't take the focus, the application that has focus, looses it. Here's some code: <code> Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click 'How do I set focus to application currently(before mouseclick) having focus? SendKeys.Send("B") End Sub Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click 'How do I set focus to application currently(before mouseclick) having focus? SendKeys.Send("A") End Sub Private Const WM_MOUSEACTIVATE As Integer = &H21 Private Const MA_NOACTIVATE As Integer = 3 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = WM_MOUSEACTIVATE Then 'We don't want to be activated m.Result = New IntPtr(MA_NOACTIVATE) Return End If MyBase.WndProc(m) End Sub </code> Regards Lars Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = Win32.WM_MOUSEACTIVATE Then 'We don't want to be activated m.Result = New IntPtr(Win32.MA_NOACTIVATE) Return End If MyBase.WndProc(m) End Sub The value of WM_MOUSEACTIVATE is &H21 The value of MA_NOACTIVATE is 3 Quote
sidlaw Posted June 7, 2004 Posted June 7, 2004 If you find an answer tothis problem please let me know I have been woking on this for 4 weeks. I have tried using a timer to record the last actvie window and then set this as the active window before using send keys. This works fine on most things accept the IE explorer bar and common dialogue open and save, because these controls a really a combo box so when the focu is returned all the text is highlighted. Somebody help please cheers Sid Quote
AlexCode Posted June 7, 2004 Posted June 7, 2004 This idea only works if you only want the virtual keyboard to work on your .net application. Instead of creating 2 windows, why don't you place the keyboard on the form? :D Create a "Master" form, where all the others inherit from witch have this keyboard functionality... a bottom docked panel with the keys or something... You could even have a global "flag" that persist the VKeyboard state in memory, so all windows woud have it visible or hided. This is just an idea... Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
sidlaw Posted June 8, 2004 Posted June 8, 2004 (edited) Sorry AlexCode, This wouldnt work for my app. sid Edited June 8, 2004 by sidlaw Quote
AlexCode Posted June 8, 2004 Posted June 8, 2004 It was an idea! :cool: Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.