Skip to content

Commit 0cc4f07

Browse files
committed
Added WM_CLOSE handling back.
1 parent 1f6fb89 commit 0cc4f07

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

TouchScript.Inputs/TouchScript.Windows/InputSources/Win7TouchInput.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ private IntPtr wndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
154154
case WM_TOUCH:
155155
decodeTouches(wParam, lParam);
156156
return IntPtr.Zero;
157+
case WM_CLOSE:
158+
// Not having this crashes app on quit
159+
UnregisterTouchWindow(hWnd);
160+
SetWindowLongPtr(hWnd, -4, oldWndProcPtr);
161+
SendMessage(hWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
162+
return IntPtr.Zero;
157163
default:
158164
return CallWindowProc(oldWndProcPtr, hWnd, msg, wParam, lParam);
159165
}
@@ -214,6 +220,7 @@ private void decodeTouches(IntPtr wParam, IntPtr lParam)
214220
#region p/invoke
215221

216222
// Touch event window message constants [winuser.h]
223+
private const int WM_CLOSE = 0x0010;
217224
private const int WM_TOUCH = 0x0240;
218225

219226
// Touch API defined structures [winuser.h]
@@ -245,6 +252,9 @@ private IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
245252
return new IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32()));
246253
}
247254

255+
[DllImport("user32.dll", CharSet = CharSet.Auto)]
256+
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
257+
248258
[DllImport("user32.dll")]
249259
private static extern IntPtr GetForegroundWindow();
250260

TouchScript.Inputs/TouchScript.Windows/InputSources/Win8TouchInput.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ private IntPtr wndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
145145
case WM_POINTERUPDATE:
146146
decodeTouches(msg, wParam, lParam);
147147
return IntPtr.Zero;
148+
case WM_CLOSE:
149+
// Not having this crashes app on quit
150+
SetWindowLongPtr(hWnd, -4, oldWndProcPtr);
151+
SendMessage(hWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
152+
return IntPtr.Zero;
148153
default:
149154
return CallWindowProc(oldWndProcPtr, hWnd, msg, wParam, lParam);
150155
}
@@ -206,6 +211,7 @@ private void decodeTouches(uint msg, IntPtr wParam, IntPtr lParam)
206211
#region p/invoke
207212

208213
// Touch event window message constants [winuser.h]
214+
private const int WM_CLOSE = 0x0010;
209215
private const int WM_TOUCH = 0x0240;
210216
private const int WM_POINTERDOWN = 0x0246;
211217
private const int WM_POINTERUP = 0x0247;
@@ -270,6 +276,9 @@ private IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
270276
return new IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32()));
271277
}
272278

279+
[DllImport("user32.dll", CharSet = CharSet.Auto)]
280+
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
281+
273282
[DllImport("user32.dll")]
274283
private static extern IntPtr GetForegroundWindow();
275284

0 commit comments

Comments
 (0)