mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-08 10:34:47 +08:00
msg loop tweaks & intptr cleanup.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Interop;
|
||||
|
||||
@@ -18,13 +19,13 @@ namespace NTwain.Internals
|
||||
{
|
||||
_filter = filter;
|
||||
|
||||
// hook into windows msg loop for old twain to post msgs.
|
||||
// the style values are purely guesses here with
|
||||
// CS_NOCLOSE, WS_DISABLED, and WS_EX_NOACTIVATE
|
||||
HwndSource win = null;
|
||||
try
|
||||
{
|
||||
win = new HwndSource(0x0200, 0x8000000, 0x8000000, 0, 0, "NTWAIN_LOOPER", IntPtr.Zero);
|
||||
// hook into windows msg loop for old twain to post msgs.
|
||||
// the style values are purely guesses here with
|
||||
// CS_NOCLOSE, WS_TILEDWINDOW, and WS_EX_APPWINDOW
|
||||
win = new HwndSource(0x0200, 0xCF0000, 0x40000, 0, 0, "NTWAIN_LOOPER", IntPtr.Zero);
|
||||
Handle = win.Handle;
|
||||
win.AddHook(WndProc);
|
||||
_win = win;
|
||||
@@ -43,6 +44,13 @@ namespace NTwain.Internals
|
||||
{
|
||||
handled = _filter.IsTwainMessage(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
Debug.WriteLine("Hwnd=" + hwnd);
|
||||
handled = true;
|
||||
// unnecessary to do default wndproc?
|
||||
return NativeMethods.DefWindowProc(hwnd, (uint)msg, wParam, lParam);
|
||||
}
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
@@ -58,6 +66,7 @@ namespace NTwain.Internals
|
||||
((HwndSource)_win).RemoveHook(WndProc);
|
||||
_win.Dispose();
|
||||
_win = null;
|
||||
Handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user