Exception in WindowFromPoint on Emulator

  • Thread starter Richard Dutrulle
  • Start date
R

Richard Dutrulle

Hello,
This code product an exception (NotSupportedException) at WindowFromPoint
fonction on Emulator CF (Pocket PC).
IntPtr Handle(Control control)
{
IntPtr hdl = (IntPtr) 0;
Point p = new Point();
Point pp = new Point();
p.X = control.Left;
p.Y = control.Top;
Win32.Point ppp = new Win32.Point();
pp = control.PointToScreen(p);
ppp.x = pp.X + 1;
ppp.y = pp.Y + 1;
hdl = Win32.WindowFromPoint(ppp);
return hdl;
}

public struct Point {

public Int32 x, y;

#if false

public Point(int p1, int p2)

{

x = p1;

y = p2;

}

#endif

}

#if(Win32)

[DllImport("User32", EntryPoint="WindowFromPoint")]

#else

[DllImport("CoreDll", EntryPoint="WindowFromPoint")]

#endif

public static extern IntPtr WindowFromPoint(Point p);
 
A

Alex Yakhnin, eMVP

Disregard the proviouse post.

Just change the datatype for your Point struct from In32 to Int16.

--
Alex Yakhnin, Microsoft Embedded MVP
IntelliProg, Inc.
http://www.intelliprog.com

Alex Yakhnin said:
Make your Point a class or change the parameter to pass by reference.

--
Alex Yakhnin, Microsoft Embedded MVP
IntelliProg, Inc.
http://www.intelliprog.com

Richard Dutrulle said:
Hello,
This code product an exception (NotSupportedException) at WindowFromPoint
fonction on Emulator CF (Pocket PC).
IntPtr Handle(Control control)
{
IntPtr hdl = (IntPtr) 0;
Point p = new Point();
Point pp = new Point();
p.X = control.Left;
p.Y = control.Top;
Win32.Point ppp = new Win32.Point();
pp = control.PointToScreen(p);
ppp.x = pp.X + 1;
ppp.y = pp.Y + 1;
hdl = Win32.WindowFromPoint(ppp);
return hdl;
}

public struct Point {

public Int32 x, y;

#if false

public Point(int p1, int p2)

{

x = p1;

y = p2;

}

#endif

}

#if(Win32)

[DllImport("User32", EntryPoint="WindowFromPoint")]

#else

[DllImport("CoreDll", EntryPoint="WindowFromPoint")]

#endif

public static extern IntPtr WindowFromPoint(Point p);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top