SP2 TextBox.Focus event problem

  • Thread starter Thread starter Stephane Tombeur
  • Start date Start date
S

Stephane Tombeur

Hi,

My application uses the TextBox.Focus event to display the SIP (through
P/Invoke).

When using SP2 this causes the application to terminate unexpectedly when I
click in a textbox.
Anyone have an idea what causes this ?

thanks,

Stephane Tombeur
 
My application is written for the 'generic' winCE 4.1 platform. I thought
a menu control to be able to use the SIP was only necessary on PocketPC ?
Or am I wrong ?

thanks,

Stephane
 
Stephane,

I do write for generic CE 4.1 devices, but I have a menu so I'm not totally
sure either. It might be worth a try though.
 
Stephane,

I do write for generic CE 4.1 devices, but I have a menu so I'm not
totally sure either. It might be worth a try though.

I'll give it a go, but It'll have to wait until after the holidays. (I
really need a vacation...)

Thanks for the advice!

Happy holidays,

Stephane
 
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

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

--------------------
| From: Stephane Tombeur <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: SP2 TextBox.Focus event problem
| Date: 18 Dec 2003 10:00:57 GMT
| Organization: Your Company
| Lines: 12
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 195.207.140.118
| X-Trace: reader08.wxs.nl 1071741657 28696 195.207.140.118 (18 Dec 2003
10:00:57 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 18 Dec 2003 10:00:57 GMT
| User-Agent: Xnews/5.04.25
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
..phx.gbl!newsfeed00.sul.t-online.de!t-online.de!newsfeed.icl.net!newsfeed.fj
serv.net!skynet.be!newsgate.cistron.nl!news.cambrium.nl!news.cambrium.nl!new
s.cambrium.nl!newsfeed.wxs.nl!textnews.wxs.nl!not-for-mail
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:41250
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
|
| My application uses the TextBox.Focus event to display the SIP (through
| P/Invoke).
|
| When using SP2 this causes the application to terminate unexpectedly when
I
| click in a textbox.
| Anyone have an idea what causes this ?
|
| thanks,
|
| Stephane Tombeur
|
 
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,

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
|
 
Back
Top