Hi Stephane,
Thanks for the PInvoke code you provided. I tried to repro your problem
(using your code combined with the code below), but I'm not having any
luck. I've tried both generic wince 4.2 and 4.1 images and PPC 2003
images. Let me know if you discover any new information after the holidays.
Repro:
public class TestForm : Form
{
public TestForm()
{
Button btn = new Button();
btn.Text = "Hide";
btn.Location = new Point(5, 45);
btn.Click += new EventHandler(OnBtnHide);
btn.Parent = this;
TextBox txb = new TextBox();
txb.Parent = this;
txb.GotFocus += new EventHandler(OnTestFocus);
this.Text = "Bug";
this.MinimizeBox = false;
}
private void OnBtnHide(object obj, EventArgs e)
{
Keyboard.Hide();
}
private void OnTestFocus(object obj, EventArgs e)
{
Keyboard.Show();
}
static void Main()
{
Application.Run(new TestForm());
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
***.Net Compact Framework Info***
Faq:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.a
spx
QuickStarts:
http://samples.gotdotnet.com/quickstart/CompactFramework/
Samples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/h
tml/CompactfxTechArt.asp
--------------------
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: RE: SP2 TextBox.Focus event problem
| From: Stephane Tombeur <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
| Organization: Your Company
| Message-ID: <
[email protected]>
| User-Agent: Xnews/5.04.25
| Lines: 223
| Date: Fri, 26 Dec 2003 20:42:00 GMT
| NNTP-Posting-Host: 213.132.151.39
| X-Complaints-To: (e-mail address removed)
| X-Trace: amsnews02.chello.com 1072471320 213.132.151.39 (Fri, 26 Dec 2003
20:42:00 WET)
| NNTP-Posting-Date: Fri, 26 Dec 2003 20:42:00 WET
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!newsfeed.wirehub.nl!amsnews0
1.chello.com!amsnews02.chello.com.POSTED!53ab2750!not-for-mail
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:41730
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Katie,
|
| The p/invoke code we use is inline at the bottom.
|
| The scenario is as follows : I start an application with multiple forms.
Only
| one of them is showing (non-modal). When a textbox on the form receives
| focus, we call Show() on the Keyboard class. This in turn calls
SIPShowIM()
| through p/invoke. As I said earlier, there is no menu control on the
form,
| nor is there an InputMethod control.
|
| I'd like to try it out myself in a simple application to rule out a
number of
| other things, but I can't right now (it'll have to wait until after the
| holidays). It's just strange to get this kind of behavior with SP2 as it
| works fine with SP1.
|
| Regards,
|
| Stephane
|
| ----------- start code -----------
|
| using System;
| using System.Runtime.InteropServices;
| using System.Drawing;
| using Microsoft.WindowsCE.Forms;
|
| namespace Nmbs.Ibis.Windows
| {
| internal enum EnumSIPKind
| {
| Klein,
| Groot,
| Ibis
| }
|
| public class Keyboard
| {
| #region DllImports
|
| [DllImport("coredll.dll")]
| private static extern int SipShowIM(SIPStatus i);
|
| [DllImport("coredll.dll")]
| private static extern int GetLastError();
|
| [DllImport("coredll.dll")]
| private static extern bool SipSetInfo(out SIPINFO info);
|
| [DllImport("coredll.dll")]
| private static extern bool SipGetInfo(out SIPINFO info);
|
| [DllImport("coredll.dll")]
| private static extern int SipSetCurrentIM(byte[] clsId);
|
|
| #endregion
|
| #region Constants
|
| private const string CLSID_GROOT="A523DFC7-1A7E-4af6-991A-
| 510E75847828";
| private const string CLSID_KLEIN="42429667-ae04-11d0-a4f8-
| 00aa00a749b9";
| private const string CLSID_IBIS="A26AB2C2-4010-4e9e-ABC1-
| 0CD90608D696";
| #endregion
|
| #region Structs
|
| [StructLayout(LayoutKind.Sequential)]
| public struct RECT
| {
| public int left;
| public int top;
| public int right;
| public int bottom;
| }
|
| [StructLayout(LayoutKind.Sequential)]
| private struct SIPINFO
| {
| public uint cbSize;
| public uint fdwFlags;
| public RECT rcVisibleDesktop;
| public RECT rcSipRect;
| public uint dwImDataSize;
| public IntPtr pvImData;
| }
|
| #endregion
|
| static Keyboard()
| {
| Hide();
| ActivateNamedSIP(EnumSIPKind.Ibis);
| SetNamedLocation(EnumSIPKind.Ibis);
| }
|
| ~Keyboard()
| {
| Hide();
| }
|
| private Keyboard() {}
|
| private static SIPStatus status = SIPStatus.SIPF_OFF;
|
| private enum SIPStatus : uint
| {
| SIPF_OFF = 0,
| SIPF_ON = 1,
| SIPF_DOCKED = 2,
| SIPF_LOCKED = 4,
| SIPF_1 = 8,
| SIPF_2 = 16,
| SIPF_CUSTOM = 32
| };
|
| private enum SIPKind
| {
| SIP1=0,
| SIP2=1
| }
|
| private enum StructSizes : uint
| {
| RECT = 16,
| SIPINFO = 48
| }
|
| public static void Show()
| {
| SipShowIM(SIPStatus.SIPF_ON);
| status = SIPStatus.SIPF_ON;
| }
|
| public static void Hide()
| {
| SipShowIM(SIPStatus.SIPF_OFF);
| status = SIPStatus.SIPF_OFF;
| }
|
| public static void Toggle()
| {
| switch(status)
| {
| case SIPStatus.SIPF_OFF:
| Show();
| break;
| case SIPStatus.SIPF_ON:
| Hide();
| break;
| }
| }
|
| private static bool SetLocation(int offsetFromLeft, int
| offsetFromTop)
| {
| SIPINFO info = new SIPINFO();
| info.cbSize = (uint) StructSizes.SIPINFO;
| if (SipGetInfo(out info))
| {
| info.rcSipRect.right = (info.rcSipRect.right -
| info.rcSipRect.left) + offsetFromLeft;
| info.rcSipRect.left = offsetFromLeft;
|
| info.rcSipRect.bottom = (info.rcSipRect.bottom -
| info.rcSipRect.top) + offsetFromTop;
| info.rcSipRect.top = offsetFromTop;
|
| return SipSetInfo(out info);
| }
| return false;
| }
|
| private static void SetNamedLocation(EnumSIPKind sipKind)
| {
| switch (sipKind)
| {
| case EnumSIPKind.Klein:
| SetLocation(396, 334);
| break;
| case EnumSIPKind.Groot:
| SetLocation(100, 100);
| break;
| case EnumSIPKind.Ibis:
| SetLocation(205,315);
| break;
| }
| }
|
| private static void ActivateNamedSIP(EnumSIPKind sipKind)
| {
| Guid g = Guid.Empty;
| switch (sipKind)
| {
| case EnumSIPKind.Klein:
| g = new Guid(CLSID_KLEIN);
| break;
| case EnumSIPKind.Groot:
| g = new Guid(CLSID_GROOT);
| break;
| case EnumSIPKind.Ibis:
| g = new Guid(CLSID_IBIS);
| break;
| }
|
| SipSetCurrentIM(g.ToByteArray());
| }
|
| }
| }
|
| ----------- end code -----------
|
|
| > Hi Stephane,
| >
| > If you don't mind posting some code, I'd like to take a look at this.
| > (Just show me what your PInvoke looks like and I can start from
| > there).
| >
| > -Katie
|