Files
ntwain/NTwain/Triplets/DGControl/DGControl.Parent.cs

52 lines
2.1 KiB
C#
Raw Normal View History

2014-04-02 19:13:15 -04:00
using System;
2014-04-02 19:01:21 -04:00
using NTwain.Data;
using NTwain.Values;
using System.Runtime.InteropServices;
namespace NTwain.Triplets
{
2014-04-04 22:19:16 -04:00
/// <summary>
/// Represents <see cref="DataArgumentType.Parent"/>.
/// </summary>
2014-04-02 19:01:21 -04:00
sealed class Parent : OpBase
{
2014-04-05 16:48:28 -04:00
internal Parent(ITwainStateInternal session) : base(session) { }
2014-04-02 19:01:21 -04:00
/// <summary>
/// When the application has closed all the Sources it had previously opened, and is finished with
/// the Source Manager (the application plans to initiate no other TWAIN sessions), it must close
/// the Source Manager.
/// </summary>
/// <param name="handle">The handle. On Windows = points to the window handle (hWnd) that will act as the Sources
/// "parent". On Macintosh = should be a NULL value.</param>
/// <returns></returns>
2014-04-05 18:33:21 -04:00
public ReturnCode CloseDsm(IntPtr handle)
2014-04-02 19:01:21 -04:00
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Parent, Message.CloseDsm);
2014-04-16 06:53:05 -04:00
var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.CloseDsm, ref handle);
2014-04-02 19:01:21 -04:00
if (rc == ReturnCode.Success)
{
2014-04-04 07:25:11 -04:00
Session.ChangeState(2, true);
2014-04-02 19:01:21 -04:00
}
return rc;
}
/// <summary>
/// Causes the Source Manager to initialize itself. This operation must be executed before any other
/// operations will be accepted by the Source Manager.
/// </summary>
/// <param name="handle">The handle. On Windows = points to the window handle (hWnd) that will act as the Sources
/// "parent". On Macintosh = should be a NULL value.</param>
/// <returns></returns>
2014-04-05 18:33:21 -04:00
public ReturnCode OpenDsm(IntPtr handle)
2014-04-02 19:01:21 -04:00
{
Session.VerifyState(1, 2, DataGroups.Control, DataArgumentType.Parent, Message.OpenDsm);
2014-04-16 06:53:05 -04:00
var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.OpenDsm, ref handle);
2014-04-02 19:01:21 -04:00
if (rc == ReturnCode.Success)
{
2014-04-04 07:25:11 -04:00
Session.ChangeState(3, true);
2014-04-02 19:01:21 -04:00
}
return rc;
}
}
}