Re: Interaction between the classes
From: Luca (Luca_at_discussions.microsoft.com)
Date: 07/13/04
- Next message: vish: "Re: Image error"
- Previous message: Dave52: "RE: NumericUpDown and DomainUpDown"
- In reply to: Chris Tacke, eMVP: "Re: Interaction between the classes"
- Next in thread: Chris Tacke, eMVP: "Re: Interaction between the classes"
- Reply: Chris Tacke, eMVP: "Re: Interaction between the classes"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 13 Jul 2004 08:46:03 -0700
Look at this code, please:
Option Explicit On
Imports System
Imports System.Windows.Forms
Imports owf = OpenNETCF.Windows.Forms
Imports mwf = Microsoft.WindowsCE.Forms
Public Class myKeyClass Implements owf.IMessageFilter
Overridable Function PreFilterMessage(ByRef m As mwf.Message) As Boolean Implements owf.IMessageFilter.PreFilterMessage
Try
Dim key As Integer = m.WParam.ToInt32()
Select Case CType(m.Msg, owf.WinMsg)
Case owf.WinMsg.WM_CHAR
Select Case key
Case 13 'ENTER key pressed
' ????????????
Return True
End Select 'key
End Select 'm.Msg
Return False
Catch ex As Exception
Return False
MsgBox(ex.ToString)
End Try
End Function
End Class
======================= Usage of above class =======================
Option Explicit On
Imports OpenNETCF.Windows.Forms
Public Class AppExTest
Inherits System.Windows.Forms.Form
Private objMyKeyClass As New myKeyClass
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
ApplicationEx.AddMessageFilter(objMyKeyClass)
'Add any initialization after the InitializeComponent() call
End Sub
#End Region
Public Shared Sub Main()
ApplicationEx.Run(New AppExTest)
End Sub
Private Sub AppExTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = ""
TextBox1.Focus()
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ApplicationEx.RemoveMessageFilter(objMyKeyClass)
ApplicationEx.Exit()
End Sub
End Class
How can I call Button1_Click if the user press Enter key ?
Thanks, Luca
"Chris Tacke, eMVP" wrote:
> I'm confused. The IMessageFilter won't have any buttons - it simply
> intercepts all messages to the application, allowing you to react to them
> before they are dispatched to the system.
>
> --
> Chris Tacke, eMVP
> Co-Founder and Advisory Board Member
> www.OpenNETCF.org
> ---
> ---
> Principal Partner
> OpenNETCF Consulting
> www.OpenNETCF.com
>
>
>
> "Luca" <Luca@discussions.microsoft.com> wrote in message
> news:3575E50E-A407-45DF-A027-29B100E44BFC@microsoft.com...
> > I'm trying to emulate the TAB and ENTER key with two hardware buttons of
> my PDA, using VB.NET and an implementation of iMessageFilter of OpenNETCF.
> > My question is: if I have to emulate the click of a button that is not in
> the filter class, but in the form class, how do I do this ?
> >
> > Thanks, Luca
>
>
>
- Next message: vish: "Re: Image error"
- Previous message: Dave52: "RE: NumericUpDown and DomainUpDown"
- In reply to: Chris Tacke, eMVP: "Re: Interaction between the classes"
- Next in thread: Chris Tacke, eMVP: "Re: Interaction between the classes"
- Reply: Chris Tacke, eMVP: "Re: Interaction between the classes"
- Messages sorted by: [ date ] [ thread ]