Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!....

  • *Gurus*
Posted

   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

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

  • 2 months later...
Posted

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

  • 2 months later...
Posted

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

Posted

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

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...