mirror of
https://github.com/soukoku/ntwain.git
synced 2026-01-26 21:48:36 +08:00
Add stepdown for currently supported state levels
This commit is contained in:
@@ -22,6 +22,7 @@ namespace NTwain.Triplets
|
||||
STS rc;
|
||||
if ((rc = DoIt(MSG.OPENDSM, ref hwnd)) == STS.SUCCESS)
|
||||
{
|
||||
Session._hwnd = hwnd;
|
||||
Session.State = STATE.S3;
|
||||
// determine memory mgmt routines used
|
||||
if ((((DG)Session._appIdentityLegacy.SupportedGroups) & DG.DSM2) == DG.DSM2)
|
||||
@@ -46,8 +47,9 @@ namespace NTwain.Triplets
|
||||
STS rc;
|
||||
if ((rc = DoIt(MSG.CLOSEDSM, ref hwnd)) == STS.SUCCESS)
|
||||
{
|
||||
Session.State = STATE.S2;
|
||||
Session._hwnd = IntPtr.Zero;
|
||||
Session._entryPoint = default;
|
||||
Session.State = STATE.S2;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
// this file contains initialization-related things.
|
||||
// this file contains initialization/cleanup things.
|
||||
|
||||
public partial class TwainSession
|
||||
{
|
||||
@@ -83,5 +83,22 @@ namespace NTwain
|
||||
DGImage = new DGImage(this);
|
||||
DGAudio = new DGAudio(this);
|
||||
}
|
||||
|
||||
internal IntPtr _hwnd;
|
||||
|
||||
/// <summary>
|
||||
/// Tries to bring the TWAIN session down to some state.
|
||||
/// </summary>
|
||||
/// <param name="targetState"></param>
|
||||
/// <returns>The final state.</returns>
|
||||
public STATE TryStepdown(STATE targetState)
|
||||
{
|
||||
if (State > targetState)
|
||||
{
|
||||
// shouldn't care about handle when closing really
|
||||
DGControl.Parent.CloseDSM(ref _hwnd);
|
||||
}
|
||||
return State;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user