示例#1
0
        private bool FilterMessage(NativeStructs.tagMSG msg)
        {
            if (twEvent.pEvent == IntPtr.Zero)
            {
                twEvent.pEvent = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NativeStructs.tagMSG)));
            }

            Marshal.StructureToPtr(msg, twEvent.pEvent, false);

            ResultCode rc = twainEvent(ref appId, ref deviceId, DataGroup.Control, DataArgumentType.Event, TwainMessages.ProcessEvent, ref twEvent);

            if (rc != ResultCode.DSEvent && rc != ResultCode.NotDSEvent)
            {
                return(false);
            }

            switch (twEvent.TWMessage)
            {
            case TwainMessages.XferReady:
                this.state     = TwainState.TransferReady;
                this.latestDIB = DoOneTransfer();
                break;

            case TwainMessages.CloseDSReq:
                this.latestDIB = IntPtr.Zero;
                DisableSource();
                this.breakModalLoop = true;
                break;

            default:
                break;
            }

            return(rc == ResultCode.DSEvent);
        }
 internal static extern bool TranslateMessage([In()] ref NativeStructs.tagMSG lpMsg);
 internal static extern IntPtr DispatchMessage([In()] ref NativeStructs.tagMSG lpMsg);
 internal static extern int GetMessage([Out()] out NativeStructs.tagMSG lpMsg, [In()] System.IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);