Removed MSG dependency on WindowsBase

This commit is contained in:
soukoku
2014-04-05 20:30:49 -04:00
parent 3dc90eff89
commit 5385cc6921
4 changed files with 26 additions and 13 deletions

View File

@@ -9,7 +9,6 @@ using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Windows.Interop;
namespace NTwain namespace NTwain
{ {
@@ -533,7 +532,7 @@ namespace NTwain
/// </summary> /// </summary>
/// <param name="message">The message.</param> /// <param name="message">The message.</param>
/// <returns>True if handled by TWAIN.</returns> /// <returns>True if handled by TWAIN.</returns>
protected bool HandleWndProcMessage(ref MSG message) protected bool HandleWndProcMessage(ref MESSAGE message)
{ {
if (State >= 4) // technically we should only handle on state >= 5 but there might be missed msgs if we wait until state changes after enabling ds if (State >= 4) // technically we should only handle on state >= 5 but there might be missed msgs if we wait until state changes after enabling ds
{ {
@@ -604,5 +603,22 @@ namespace NTwain
} }
#endregion #endregion
/// <summary>
/// The MSG structure in Windows for TWAIN use.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
protected struct MESSAGE
{
public IntPtr hwnd;
public uint message;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public int x;
public int y;
}
} }
} }

View File

@@ -7,7 +7,6 @@ using NTwain.Data;
using NTwain.Values; using NTwain.Values;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Interop;
using System.Diagnostics; using System.Diagnostics;
using System.Security.Permissions; using System.Security.Permissions;
using System.IO; using System.IO;
@@ -246,10 +245,10 @@ namespace NTwain
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
bool IMessageFilter.PreFilterMessage(ref System.Windows.Forms.Message m) bool IMessageFilter.PreFilterMessage(ref System.Windows.Forms.Message m)
{ {
MSG winmsg = default(MSG); MESSAGE winmsg = default(MESSAGE);
winmsg.hwnd = m.HWnd; winmsg.hwnd = m.HWnd;
winmsg.lParam = m.LParam; winmsg.lParam = m.LParam;
winmsg.message = m.Msg; winmsg.message = (uint)m.Msg;
winmsg.wParam = m.WParam; winmsg.wParam = m.WParam;
return HandleWndProcMessage(ref winmsg); return HandleWndProcMessage(ref winmsg);
@@ -267,10 +266,10 @@ namespace NTwain
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)] [EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{ {
MSG winmsg = default(MSG); MESSAGE winmsg = default(MESSAGE);
winmsg.hwnd = hwnd; winmsg.hwnd = hwnd;
winmsg.lParam = lParam; winmsg.lParam = lParam;
winmsg.message = msg; winmsg.message = (uint)msg;
winmsg.wParam = wParam; winmsg.wParam = wParam;
handled = base.HandleWndProcMessage(ref winmsg); handled = base.HandleWndProcMessage(ref winmsg);

View File

@@ -5,7 +5,6 @@ using System.Linq;
using System.Security.Permissions; using System.Security.Permissions;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Interop;
namespace NTwain namespace NTwain
{ {
@@ -34,10 +33,10 @@ namespace NTwain
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)] [EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{ {
MSG winmsg = default(MSG); MESSAGE winmsg = default(MESSAGE);
winmsg.hwnd = hwnd; winmsg.hwnd = hwnd;
winmsg.lParam = lParam; winmsg.lParam = lParam;
winmsg.message = msg; winmsg.message = (uint)msg;
winmsg.wParam = wParam; winmsg.wParam = wParam;
handled = base.HandleWndProcMessage(ref winmsg); handled = base.HandleWndProcMessage(ref winmsg);

View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Interop;
namespace NTwain namespace NTwain
{ {
@@ -25,10 +24,10 @@ namespace NTwain
bool IMessageFilter.PreFilterMessage(ref Message m) bool IMessageFilter.PreFilterMessage(ref Message m)
{ {
MSG winmsg = default(MSG); MESSAGE winmsg = default(MESSAGE);
winmsg.hwnd = m.HWnd; winmsg.hwnd = m.HWnd;
winmsg.lParam = m.LParam; winmsg.lParam = m.LParam;
winmsg.message = m.Msg; winmsg.message = (uint)m.Msg;
winmsg.wParam = m.WParam; winmsg.wParam = m.WParam;
return HandleWndProcMessage(ref winmsg); return HandleWndProcMessage(ref winmsg);