From: Andy Baker on
We are using a windows CE5 / CF2 device that has a single button to change
the input mode from numeric - alpha - capitals and I need to be able to
control the input mode from my application. There are 3 problems that I need
to solve:
1) Change the input mode from my application
2) Get the current input mode
3) Detect when the input mode has been changed

Unfortunately for me the manufacturer doesn't provide any SDK functions to
enable me to do any of these from my VB.NET application. They do provide an
..exe file, called tsIM_Mode.exe, that runs as an icon in the taskbar and
displays the current input mode - it displays either 1, A or a, depending on
the current input mode. When you tap this icon it has the same effect as
when you press the input mode key. I have been trying to send windows
messages to the tsIM_Mode.exe to get it to change modes but am not having
much (any) success. The code I am using is as follows:

'To get a handle to the key application
<DllImport("coredll.dll), SetLastError=True)> _
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal
lpWindowName as String)
Dim targetWnd as Intptr = FindWindow(Nothing, "tsIM_Mode")

'To send a Mouse Click

Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202

MessageWindow.SendMessage(Message.Create(targetWnd, WM_LBUTTONDOWN,
IntPtr.Zero, IntPtr.Zero)
MessageWindow.SendMessage(Message.Create(targetWnd, WM_LBUTTONUP,
IntPtr.Zero, IntPtr.Zero)

All calls succeed and targetWnd contains a valid handle - although whether
it is actually the one I want I am not sure - but nothing happens to the
input mode. I have tried P/Invoking the SendMessage and PostMessage
functions instead of using
Microsoft.WindowsCE.Forms.MessageWindow.SendMessage but still the same
result. My questions are 1) Is what I want to do actually possible? and 2)
How can I check that I have got the correct handle and am sending the
correct messages.

Parts 2) and 3) are even more difficult. I don't really know where to start
on getting the current input mode - my thoughts were simulating a keypress
somehow and looking at what was output or reading the displayed icon of the
tsIM_Mode.exe application. For checking whether the key has been pressed on
other devices I have used the OpenNETCF IMessageFilter and checked for the
WM_KEYDOWN (or WM_SYSKEYDOWN) messages successfully. Unfortunately my
application doesn't get a message when the Input Mode key is pressed on this
particular device (it does for every other key).

Any suggestions would be appreciated. Thanks in advance.

Andy Baker




From: Peter Foot [MVP] on
Try P/Invoking mouse_event this will simulate an actual mouse (touch screen)
action. See the MSDN documentation for the method to see how to convert
mouse co-ordinates.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - software solutions for a mobile world
In The Hand Ltd - .NET Components for Mobility

"Andy Baker" <abaker(a)NOSPAMvanputer.com> wrote in message
news:vc6dnVpJV_YjDD7WnZ2dnUVZ8iOdnZ2d(a)brightview.co.uk...
> We are using a windows CE5 / CF2 device that has a single button to change
> the input mode from numeric - alpha - capitals and I need to be able to
> control the input mode from my application. There are 3 problems that I
> need to solve:
> 1) Change the input mode from my application
> 2) Get the current input mode
> 3) Detect when the input mode has been changed
>
> Unfortunately for me the manufacturer doesn't provide any SDK functions to
> enable me to do any of these from my VB.NET application. They do provide
> an .exe file, called tsIM_Mode.exe, that runs as an icon in the taskbar
> and displays the current input mode - it displays either 1, A or a,
> depending on the current input mode. When you tap this icon it has the
> same effect as when you press the input mode key. I have been trying to
> send windows messages to the tsIM_Mode.exe to get it to change modes but
> am not having much (any) success. The code I am using is as follows:
>
> 'To get a handle to the key application
> <DllImport("coredll.dll), SetLastError=True)> _
> Private Shared Function FindWindow(ByVal lpClassName As String, ByVal
> lpWindowName as String)
> Dim targetWnd as Intptr = FindWindow(Nothing, "tsIM_Mode")
>
> 'To send a Mouse Click
>
> Const WM_LBUTTONDOWN = &H201
> Const WM_LBUTTONUP = &H202
>
> MessageWindow.SendMessage(Message.Create(targetWnd, WM_LBUTTONDOWN,
> IntPtr.Zero, IntPtr.Zero)
> MessageWindow.SendMessage(Message.Create(targetWnd, WM_LBUTTONUP,
> IntPtr.Zero, IntPtr.Zero)
>
> All calls succeed and targetWnd contains a valid handle - although whether
> it is actually the one I want I am not sure - but nothing happens to the
> input mode. I have tried P/Invoking the SendMessage and PostMessage
> functions instead of using
> Microsoft.WindowsCE.Forms.MessageWindow.SendMessage but still the same
> result. My questions are 1) Is what I want to do actually possible? and 2)
> How can I check that I have got the correct handle and am sending the
> correct messages.
>
> Parts 2) and 3) are even more difficult. I don't really know where to
> start on getting the current input mode - my thoughts were simulating a
> keypress somehow and looking at what was output or reading the displayed
> icon of the tsIM_Mode.exe application. For checking whether the key has
> been pressed on other devices I have used the OpenNETCF IMessageFilter and
> checked for the WM_KEYDOWN (or WM_SYSKEYDOWN) messages successfully.
> Unfortunately my application doesn't get a message when the Input Mode key
> is pressed on this particular device (it does for every other key).
>
> Any suggestions would be appreciated. Thanks in advance.
>
> Andy Baker
>
>
>
>
From: Andy Baker on
Thanks for the reply. If I understand the documentation for mouse_event
correctly I would need to supply co-ordinates for the mouse click, but the
icon I want to to click on is not always visible as it is on the hidden
taskbar so I don't think I could do it that way. However the manufacturer
has today told me that they will supply SDK functions to get and set the
input modes so that should get me out of trouble.

"Peter Foot [MVP]" <feedback(a)inthehand.com> wrote in message
news:CE6A468D-6D10-428E-82CF-9ECB26538DDF(a)microsoft.com...
> Try P/Invoking mouse_event this will simulate an actual mouse (touch
> screen) action. See the MSDN documentation for the method to see how to
> convert mouse co-ordinates.
>
> Peter
>
> --
> Peter Foot
> Microsoft Device Application Development MVP
> peterfoot.net | appamundi.com | inthehand.com
> APPA Mundi Ltd - software solutions for a mobile world
> In The Hand Ltd - .NET Components for Mobility
>
> "Andy Baker" <abaker(a)NOSPAMvanputer.com> wrote in message
> news:vc6dnVpJV_YjDD7WnZ2dnUVZ8iOdnZ2d(a)brightview.co.uk...
>> We are using a windows CE5 / CF2 device that has a single button to
>> change the input mode from numeric - alpha - capitals and I need to be
>> able to control the input mode from my application. There are 3 problems
>> that I need to solve:
>> 1) Change the input mode from my application
>> 2) Get the current input mode
>> 3) Detect when the input mode has been changed
>>
>> Unfortunately for me the manufacturer doesn't provide any SDK functions
>> to enable me to do any of these from my VB.NET application. They do
>> provide an .exe file, called tsIM_Mode.exe, that runs as an icon in the
>> taskbar and displays the current input mode - it displays either 1, A or
>> a, depending on the current input mode. When you tap this icon it has the
>> same effect as when you press the input mode key. I have been trying to
>> send windows messages to the tsIM_Mode.exe to get it to change modes but
>> am not having much (any) success. The code I am using is as follows:
>>
>> 'To get a handle to the key application
>> <DllImport("coredll.dll), SetLastError=True)> _
>> Private Shared Function FindWindow(ByVal lpClassName As String, ByVal
>> lpWindowName as String)
>> Dim targetWnd as Intptr = FindWindow(Nothing, "tsIM_Mode")
>>
>> 'To send a Mouse Click
>>
>> Const WM_LBUTTONDOWN = &H201
>> Const WM_LBUTTONUP = &H202
>>
>> MessageWindow.SendMessage(Message.Create(targetWnd, WM_LBUTTONDOWN,
>> IntPtr.Zero, IntPtr.Zero)
>> MessageWindow.SendMessage(Message.Create(targetWnd, WM_LBUTTONUP,
>> IntPtr.Zero, IntPtr.Zero)
>>
>> All calls succeed and targetWnd contains a valid handle - although
>> whether it is actually the one I want I am not sure - but nothing happens
>> to the input mode. I have tried P/Invoking the SendMessage and
>> PostMessage functions instead of using
>> Microsoft.WindowsCE.Forms.MessageWindow.SendMessage but still the same
>> result. My questions are 1) Is what I want to do actually possible? and
>> 2) How can I check that I have got the correct handle and am sending the
>> correct messages.
>>
>> Parts 2) and 3) are even more difficult. I don't really know where to
>> start on getting the current input mode - my thoughts were simulating a
>> keypress somehow and looking at what was output or reading the displayed
>> icon of the tsIM_Mode.exe application. For checking whether the key has
>> been pressed on other devices I have used the OpenNETCF IMessageFilter
>> and checked for the WM_KEYDOWN (or WM_SYSKEYDOWN) messages successfully.
>> Unfortunately my application doesn't get a message when the Input Mode
>> key is pressed on this particular device (it does for every other key).
>>
>> Any suggestions would be appreciated. Thanks in advance.
>>
>> Andy Baker
>>
>>
>>
>>


 | 
Pages: 1
Prev: System.Environment.OSVersion
Next: WCF wich CF