C
C#3mo ago
WolfDen133

touch input winforms

Hiya, Im trying to interpret touch inputs for winforms, ive overritten the WndProc, but when i touch my window no WM_TOUCH message is sent, im getting code 282 and code 528, but not code 576 which is the one i need, it is registered in user32 as a touch screen serface, any suggestions
3 Replies
Buddy
Buddy3mo ago
We do not help by DMs $details
MODiX
MODiX3mo ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, what you expect the result to be, what .NET version you are using and what platform/environment (if any) are relevant to your question. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
WolfDen133
WolfDen1333mo ago
there ya go have any idea tho? using .net7.0 framework, expecting to see code 576, but seeing stream of:
33
132
132
528
587
33
282
528
33
33
132
132
528
587
33
282
528
33
when touching and reliecing the screen
try
{
// Registering the window for multi-touch, using the default settings.
// p/invoking into user32.dll
if (!RegisterTouchWindow(this.Handle, 0))
{
Debug.Print("ERROR: Could not register window for multi-touch");
}
}
catch (Exception exception)
{
Debug.Print("ERROR: RegisterTouchWindow API not available");
Debug.Print(exception.ToString());
MessageBox.Show("RegisterTouchWindow API not available", "MTScratchpadWMTouch ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
}
try
{
// Registering the window for multi-touch, using the default settings.
// p/invoking into user32.dll
if (!RegisterTouchWindow(this.Handle, 0))
{
Debug.Print("ERROR: Could not register window for multi-touch");
}
}
catch (Exception exception)
{
Debug.Print("ERROR: RegisterTouchWindow API not available");
Debug.Print(exception.ToString());
MessageBox.Show("RegisterTouchWindow API not available", "MTScratchpadWMTouch ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
}
register code (no error messages shown when registered
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// Decode and handle WM_TOUCH message.
bool handled;
Console.WriteLine(m.Msg);
switch (m.Msg)
{
case WM_TOUCH:
handled = DecodeTouch(ref m);
break;
default:
handled = false;
break;
}

// Call parent WndProc for default message processing.
base.WndProc(ref m);

if (handled)
{
// Acknowledge event if handled.
m.Result = new System.IntPtr(1);
}
}
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// Decode and handle WM_TOUCH message.
bool handled;
Console.WriteLine(m.Msg);
switch (m.Msg)
{
case WM_TOUCH:
handled = DecodeTouch(ref m);
break;
default:
handled = false;
break;
}

// Call parent WndProc for default message processing.
base.WndProc(ref m);

if (handled)
{
// Acknowledge event if handled.
m.Result = new System.IntPtr(1);
}
}
override code, I have no idea why its not reporting the message Please help