• Announcements

    • Reminder - MoDaCo position on illegal content   07/30/15

      ILLEGAL CONTENT I'd like to just reaffirm MoDaCo's position regarding piracy and illegal content in the light of some recent questions / postings. Posts will be censored by myself or my moderation team if the contain or link to: Illegal / pirated / cracked software or sites that host such softwareNintendo emulators / ROMs or sites hosting them (in light of Nintendo's legal stance)CUSTOM ROMS You may discuss and post links to custom device ROMs on MoDaCo, provided the following rules are adhered to: ROMs must not contain any illegal 3rd party software (this includes trial versions included without permission)ROMs must give full credit to the original authorISSUES If you have any issues with this policy, please contact PaulOBrien directly via PM.
    • Reminder: Selling items on the forum directly is not allowed   07/30/15

      Please note that selling items on the forum directly is not allowed by the forum rules. There is a forum for eBay auctions whereby you can list the items on eBay and link to them there. This is the ONLY forum for this type of activity. You may also advertise links to the eBay forum in your signature. Please note that selling directly in contravention of these rules will result in a warning / suspension / ban.
Sign in to follow this  
Followers 0

Problem switching input methods

5 posts in this topic

Posted · Report post

Can anyone give me an idea why the following code doesn't correctly switch input methods when called?

Cheers,

P

Enum InputMode As Integer

IM_SPELL = &H0

IM_AMBIG = &H1

IM_NUMBERS = &H2

End Enum

_

Public Shared Function GetCapture() As IntPtr

End Function

Sub SetInputMode(ByVal InputMode As InputMode, ByVal Control As Windows.Forms.Control)

Const EM_SETINPUTMODE As Integer = &HDE

Dim wparam As New IntPtr(0)

Dim lparam As New IntPtr(InputMode)

Dim message As New Microsoft.WindowsCE.Forms.Message

Dim container As New Microsoft.WindowsCE.Forms.MessageWindow

Control.Capture = True

Dim hWnd As IntPtr = GetCapture()

Control.Capture = False

message.Create(hWnd, EM_SETINPUTMODE, wparam, lparam)

container.PostMessage(message)

End Sub

0

Share this post


Link to post
Share on other sites

Posted · Report post

I think your problem lies with this line:

message.Create(hWnd, EM_SETINPUTMODE, wparam, lparam)

Create is a shared method in the Message class, and you are try to call it from an instance of the Message class. This is not allowed. The reason why it seems to work, that is, no errors, is because you have given your instance paramater (message) the same name as the Message class, and since your coding in VB .NET, the compiler makes no beef about it.

Try this instead:

Enum InputMode As Integer

IM_SPELL = &H0

IM_AMBIG = &H1

IM_NUMBERS = &H2

End Enum

_

Public Shared Function GetFocus() As IntPtr

End Function

Sub SetInputMode(ByVal InputMode As InputMode, ByVal Control As Windows.Forms.Control)

Const EM_SETINPUTMODE As Integer = &HDE

Dim wparam As New IntPtr(0)

Dim lparam As New IntPtr(InputMode)

Dim msg As New Microsoft.WindowsCE.Forms.Message

Dim container As New Microsoft.WindowsCE.Forms.MessageWindow

Control.Capture = True

Dim hWnd As IntPtr = GetFocus()

Control.Capture = False

msg = Microsoft.WindowsCE.Forms.Message.Create(hWnd, EM_SETINPUTMODE, wparam, lparam)

container.PostMessage(ByRef msg)

End Sub

0

Share this post


Link to post
Share on other sites

Posted · Report post

Cheers, that works a treat, although the lines

Control.Capture = True

Control.Capture = False

can be omitted as we are getting the hWnd of the currently focused object rather than capturing one, hence also there is no need to pass object details on the function parameters.

Wonder why GetCapture doesn't work?

Ah well!

Cheers!

P

0

Share this post


Link to post
Share on other sites

Posted · Report post

That's very true. I was just being lazy in not trimming the code :)

It may well work witih GetCapture, I just haven't tried that.

0

Share this post


Link to post
Share on other sites

Posted · Report post

this is the c# version of the code:

using System;

using System.Windows.Forms;

using System.Runtime.InteropServices;

using Microsoft.WindowsCE.Forms;

namespace somenamespace

{

public class Forms

{

[DllImport("coredll")] public static extern IntPtr GetFocus();

public enum InputMode {IM_SPELL = 0x0, IM_AMBIG = 0x1, IM_NUMBERS = 0x2};

public Forms()

{

}

public static void SetInputMode(InputMode InputMode, System.Windows.Forms.Control Control)

{

const int EM_SETINPUTMODE = 0xDE;

IntPtr wparam = new IntPtr(0);

IntPtr lparam = new IntPtr((int)InputMode);

Message msg = new Message();

IntPtr hWnd = GetFocus();

msg = Microsoft.WindowsCE.Forms.Message.Create(hWnd, EM_SETINPUTMODE, wparam, lparam);

MessageWindow.PostMessage(ref msg);

}

}

}

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

MoDaCo is part of the MoDaCo.network, © Paul O'Brien 2002-2015. MoDaCo uses IntelliTxt technology.