示例#1
0
/*
Should be called from the main message loop of the application. Can always be called,
it will not process the message unless a scan is in progress.
*/
BOOL CTwain::ProcessMessage(MSG msg)
{
	if(SourceEnabled()){

		TW_UINT16  twRC = TWRC_NOTDSEVENT;
		TW_EVENT twEvent;

		memset(&twEvent, 0, sizeof(TW_EVENT));
	//	twEvent.TWMessage = MSG_NULL;

		twEvent.pEvent = (TW_MEMREF)&msg;

		twRC = CallDSMEntry(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);

	//	CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);
	//	if(GetRC() != TWRC_NOTDSEVENT)
	//	{
		TranslateMessage(twEvent);
	//	}

		// tell the caller what happened
		return (twRC==TWRC_DSEVENT);           // returns TRUE or FALSE
	}
	return FALSE;
}
示例#2
0
/** Should be called from the main message loop of the application. Can always be called,
    it will not process the message unless a scan is in progress.
 */
bool TwainIface::ProcessMessage(MSG msg)
{
    if(SourceEnabled())
    {
        TW_UINT16  twRC = TWRC_NOTDSEVENT;

        TW_EVENT twEvent;
        twEvent.pEvent = (TW_MEMREF)&msg;
        //memset(&twEvent, 0, sizeof(TW_EVENT));

        twEvent.TWMessage = MSG_NULL;

        CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                      DAT_EVENT, MSG_PROCESSEVENT, (TW_MEMREF)&twEvent);

        if(GetRC() != TWRC_NOTDSEVENT)
        {
            TranslateMessage(twEvent);
        }

        return (twRC==TWRC_DSEVENT);

    }
    return false;
}
/*
Gets Imageinfo for an image which is about to be transferred.
*/
BOOL CTwain::GetImageInfo(TW_IMAGEINFO& info)
{
	if(SourceEnabled())
	{
		return CallTwainProc(&m_AppId,&m_Source,DG_IMAGE,DAT_IMAGEINFO,MSG_GET,(TW_MEMREF)&info);
	}
	return FALSE;
}
示例#4
0
/** Gets Imageinfo for an image which is about to be transferred.
 */
bool TwainIface::GetImageInfo(TW_IMAGEINFO& info)
{
    if(SourceEnabled())
    {
        return CallTwainProc(&m_AppId, &m_Source, DG_IMAGE,
                             DAT_IMAGEINFO, MSG_GET, (TW_MEMREF)&info);
    }
    return false;
}
示例#5
0
/*
Should be called from the main message loop of the application. Can always be called,
it will not process the message unless a scan is in progress.
*/
BOOL CTwain::ProcessMessage(MSG msg)
{
	if(SourceEnabled())
	{
#if 1
		TW_UINT16  twRC = TWRC_NOTDSEVENT;
		TW_EVENT twEvent;

		memset(&twEvent, 0, sizeof(TW_EVENT));
		//  twEvent.TWMessage = MSG_NULL;

		twEvent.pEvent = (TW_MEMREF)&msg;

		twRC = CallDSMEntry(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);

// 		if (twRC != TWRC_DSEVENT)
// 			return FALSE;

		//  CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);
		//  if(GetRC() != TWRC_NOTDSEVENT)
		//  {

		if (!_bTwainContinue)
		{
			twEvent.TWMessage = MSG_CLOSEDSREQ;
		}

		TranslateMessage(twEvent);
		//  }

		// tell the caller what happened
		return (twRC == TWRC_DSEVENT);           // returns TRUE or FALSE
//		return TRUE;
#else
	TW_EVENT twEvent;
		twEvent.pEvent = (TW_MEMREF)&msg;
		twEvent.TWMessage = MSG_NULL;
	
		CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);
		if(GetRC() != TWRC_NOTDSEVENT)
		{
			TRACE("********** ProcessMessage ************\n");
			TranslateMessage(twEvent);
		}
		return FALSE;
#endif

	}
	else
	{
//		TRACE("********** ProcessMessage SourceEnabled = false ************\n");
	}
	return FALSE;
}
示例#6
0
/*
 Called to disable the source.
*/
BOOL CTwain::DisableSource()
{
	if(SourceEnabled())
	{
		if(CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_USERINTERFACE,MSG_DISABLEDS,&twUI))
		{
			m_bSourceEnabled = FALSE;
			return TRUE;
		}
	}
	return FALSE;
}
示例#7
0
/** Called to disable the source.
 */
bool TwainIface::DisableSource()
{
    if(SourceEnabled())
    {
        TW_USERINTERFACE twUI;
        if(CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                         DAT_USERINTERFACE, MSG_DISABLEDS, &twUI))
        {
            m_bSourceEnabled = false;
            return true;
        }
    }
    return false;
}
/*
Should be called from the main message loop of the application. Can always be called,
it will not process the message unless a scan is in progress.
*/
BOOL CTwain::ProcessMessage(MSG msg)
{
	if(SourceEnabled())
	{
	TW_EVENT twEvent;
		twEvent.pEvent = (TW_MEMREF)&msg;
		twEvent.TWMessage = MSG_NULL;
	
		CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_EVENT,MSG_PROCESSEVENT,(TW_MEMREF)&twEvent);
		if(GetRC() != TWRC_NOTDSEVENT)
		{
			TranslateMessage(twEvent);
		}
		return FALSE;

	}
	return FALSE;
}
示例#9
0
/*
Called to enable the Twain Acquire Dialog. This too can be
overridden but is a helluva job . 
*/
BOOL CTwain::EnableSource(BOOL showUI)
{
	if(DSOpen() && !SourceEnabled())
	{
		twUI.ShowUI = showUI;	//FALSE
		twUI.hParent = (TW_HANDLE)m_hMessageWnd;
		if(CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_USERINTERFACE,MSG_ENABLEDS,(TW_MEMREF)&twUI))
		{
			m_bSourceEnabled = TRUE;
			m_bModalUI = twUI.ModalUI;
		}
		else
		{
			m_bSourceEnabled = FALSE;
			m_bModalUI = TRUE;
		}
		return m_bSourceEnabled;
	}
	return FALSE;
}
示例#10
0
/** Called to enable the Twain Acquire Dialog. This too can be
    overridden but is a helluva job .
 */
bool TwainIface::EnableSource(bool showUI)
{
    if(DSOpen() && !SourceEnabled())
    {
        TW_USERINTERFACE twUI;
        twUI.ShowUI  = showUI;
        twUI.hParent = (TW_HANDLE)m_hMessageWnd;

        if(CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                         DAT_USERINTERFACE, MSG_ENABLEDS, (TW_MEMREF)&twUI))
        {
            m_bSourceEnabled = true;
            m_bModalUI       = twUI.ModalUI;
        }
        else
        {
            m_bSourceEnabled = false;
            m_bModalUI       = true;
        }
        return m_bSourceEnabled;
    }
    return false;
}