Other problems have arisen however, such as the overlap and difficulty of distinguishing between touch or mouse events, but the problem above solved with the following:
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case Win32.WM_POINTERDOWN:
case Win32.WM_POINTERUP:
case Win32.WM_POINTERUPDATE:
case Win32.WM_POINTERCAPTURECHANGED:
break;
default:
base.WndProc(ref m);
return;
}
int pointerID = Win32.GET_POINTER_ID(m.WParam);
Win32.POINTER_INFO pi = new Win32.POINTER_INFO();
if (!Win32.GetPointerInfo(pointerID, ref pi))
{
Win32.CheckLastError();
}
Point pt = PointToClient(pi.PtPixelLocation.ToPoint());
MouseEventArgs me = new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, pt.X, pt.Y, 0);
switch (m.Msg)
{
case Win32.WM_POINTERDOWN:
Console.WriteLine("TOCOU" + pt);
(Parent as Jogo).Form1_MouseDown((this as object), me);
break;
case Win32.WM_POINTERUP:
Console.WriteLine("LEVANTOU");
(Parent as Jogo).Form1_MouseUp((this as object), me);
break;
case Win32.WM_POINTERUPDATE:
//Console.WriteLine("UPDATE");
(Parent as Jogo).Form1_MouseMove((this as object), me);
break;
}
}
I used a "Win32.Cs" class that can be downloaded here:
https://dl.dropboxusercontent.com/u/4311953/Win32.cs
I hope it will be useful ;)
When you touch the screen, does the mouse cursor appear immediately at the point you touched? Or does it only appear when you move your finger? If the second case occurs, I think the problem lies in how that particular screen works. Otherwise I hope you get a good answer to your question.
– Oralista de Sistemas
I am currently testing on a Sony Vaio Tap 20, and when I use the touch instead of the mouse, the usual cursor disappears and is replaced by a circle. However, this circle appears at the moment when the touch occurs, and it is not necessary to make any kind of movement.
– Jorge Oliveira