How do I get a window's HWnd on a SMARTPHONE in Visual Basic.NET?

  • Thread starter Thread starter vbmark
  • Start date Start date
V

vbmark

How do I get a TEXTBOX's and COMBOBOX's HWnd on a SMARTPHONE in Visual
Basic.NET?

GetCapture() works on PPC but not SMARTPHONE.
 
Oh, you're right you did. Sorry about that. I realize that I didn't
understand what you were saying but I get it now. It works great.
Thanks. I moved it out of the GotFocus event and moved it to where the
control gets created and it works fine there.

Could you explain a little more indepth what you meant by this
statement:

ApplicationEx.AddMessageFilter(m_oTextBox(i))

One thign I have to say about your design - it's not a very good idea
to have each control have its own message filter. This will slow your
application to a crawl since ApplicationEx needs to invoke every
single delegate on every windows message. Since you only want keyboard
messages, keep track of which control is focused (by having Focus
event handler in your control class and setting a global variable to
reference this control). This way you could have a single message
filter where you could invoke Control's own message filter for the
active control only

I understand what the problem is but don't understand the solution.

Thanks!
 
Every time a message arrives in the application's message queue, the
ApplicationEx message pump has to call every registered message filter. If
you have 15 controls and each of them registers it's own message filter,
that 15 calls per message (and I mean all kind of messages - everything that
is posted and for every window in the application). You will be taking a
huge performance hit there. If you only care about keyboard messages you can
optimize this in a number of ways. What I suggest it to keep track of which
control has focus and only let it process keyboard messages. You do this by
a) adding Focus event handler to each control (or their common base class as
you did) and in the event handler storing the control reference in a global
Control variable and b) setting up 1 message filter and in the beginning of
it checking if the message is indeed one of the keyboard messages and then
invoking a handler (provided by you) on the currently focused control only
 
Ok, I reread your post about 25 times. I just don't understand.

I thought that this code...

Public Function PreFilterMessage(ByRef m As _
Microsoft.WindowsCE.Forms.Message) _
As Boolean Implements _
OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
Try
If m.HWnd.Equals(pHWnd) Then
Select Case m.Msg
Case &H100
myfunc.Invoke(New KeyEventArgs(m.WParam.ToInt32), _
m.LParam.ToInt32)
End Select
End If
Catch ex As Exception
'MsgBox(ex.ToString)
End Try
End Function

....made sure that the event got called correctly but I'm guessing that is
not what you mean. Could you show me what you mean in your example code?

http://www.alexfeinman.com/download.asp?doc=MessageFilterSP.zip


Thanks!
 
Back
Top