public static extern ReturnCode DsmWinNew( [In, Out] TWIdentity origin, [In, Out] TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWCallback data);
public static ReturnCode DsmEntry( TWIdentity origin, TWIdentity destination, Message msg, TWCallback data) { if (PlatformInfo.Current.IsWindows) { if (PlatformInfo.Current.UseNewWinDSM) { return(NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data)); } else { return(NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data)); } } else if (PlatformInfo.Current.IsLinux) { return(NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data)); } throw new PlatformNotSupportedException(); }
void ITwainSessionInternal.UpdateCallback() { if (State < 4) { _callbackObj = null; } else { ReturnCode rc = ReturnCode.Failure; // per the spec (8-10) apps for 2.2 or higher uses callback2 so try this first if (_appId.ProtocolMajor > 2 || (_appId.ProtocolMajor >= 2 && _appId.ProtocolMinor >= 2)) { var cb = new TWCallback2(HandleCallback); rc = ((ITwainSessionInternal)this).DGControl.Callback2.RegisterCallback(cb); if (rc == ReturnCode.Success) { PlatformInfo.Current.Log.Debug("Registered callback2 OK."); _callbackObj = cb; } } if (rc != ReturnCode.Success) { // always try old callback var cb = new TWCallback(HandleCallback); rc = ((ITwainSessionInternal)this).DGControl.Callback.RegisterCallback(cb); if (rc == ReturnCode.Success) { PlatformInfo.Current.Log.Debug("Registered callback OK."); _callbackObj = cb; } } } }
/// <summary> /// This triplet is sent to the DSM by the Application to register the application’s entry point with /// the DSM, so that the DSM can use callbacks to inform the application of events generated by the /// DS. /// </summary> /// <param name="callback">The callback.</param> /// <returns></returns> public ReturnCode RegisterCallback(TWCallback callback) { Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback); return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.RegisterCallback, callback)); }