// RasterTwainSink.cpp : implementation file // #include "stdafx.h" #include "resource.h" #include "Twain.h" #include "TwainDoc.h" #include "TwainView.h" #include "LEADRaster.h" #include "RasterTwainSink.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CRasterTwainSink IMPLEMENT_DYNCREATE(CRasterTwainSink, CCmdTarget) CRasterTwainSink::CRasterTwainSink() { EnableAutomation(); } CRasterTwainSink::~CRasterTwainSink() { } void CRasterTwainSink::OnFinalRelease() { // When the last reference for an automation object is released // OnFinalRelease is called. The base class will automatically // deletes the object. Add additional cleanup required for your // object before calling the base class. CCmdTarget::OnFinalRelease(); } BEGIN_MESSAGE_MAP(CRasterTwainSink, CCmdTarget) //{{AFX_MSG_MAP(CRasterTwainSink) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DISPATCH_MAP(CRasterTwainSink, CCmdTarget) //{{AFX_DISPATCH_MAP(CRasterTwainSink) DISP_FUNCTION_ID(CRasterTwainSink, "AcquirePageEvent", 1, OnAcquire, VT_EMPTY, VTS_I4) //}}AFX_DISPATCH_MAP END_DISPATCH_MAP() // Note: we add support for IID_IRasterTwainSink to support typesafe binding // from VBA. This IID must match the GUID that is attached to the // dispinterface in the .ODL file. BEGIN_INTERFACE_MAP(CRasterTwainSink, CCmdTarget) INTERFACE_PART(CRasterTwainSink, DIID__LEADRasterTwainEvents, Dispatch) END_INTERFACE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRasterTwainSink message handlers void CRasterTwainSink::OnAcquire (long pBitmap) { CTwainApp * pApp = (CTwainApp *)AfxGetApp(); if (pApp->m_pRaster->BitmapListCount > 0) pApp->m_pRaster->FreeList(); if (pApp->m_twXferMech != L_TWSX_FILE) { pApp->m_pRaster->InsertBitmapListItem(-1, pBitmap); pApp->CreateNewChild(); } }