// RasterThumbSink.cpp : implementation file // #include "stdafx.h" #include "demo.h" #include "RasterBrowseDlgSink.h" //#include "Demo.h" extern CDemoApp theApp; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CRasterBrowseDlgSink IMPLEMENT_DYNCREATE(CRasterBrowseDlgSink, CCmdTarget) CRasterBrowseDlgSink::CRasterBrowseDlgSink() { EnableAutomation(); } CRasterBrowseDlgSink::~CRasterBrowseDlgSink() { } void CRasterBrowseDlgSink::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(CRasterBrowseDlgSink, CCmdTarget) //{{AFX_MSG_MAP(CRasterBrowseDlgSink) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DISPATCH_MAP(CRasterBrowseDlgSink, CCmdTarget) //{{AFX_DISPATCH_MAP(CRasterBrowseDlgSink) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_DISPATCH_MAP DISP_FUNCTION_ID(CRasterBrowseDlgSink, "ThumbnailEvent", 1, OnThumbnailEvent, VT_EMPTY, VTS_I4 VTS_BSTR VTS_I2 VTS_I2) END_DISPATCH_MAP() // Note: we add support for IID_IRasterThumbSink to support typesafe binding // from VBA. This IID must match the GUID that is attached to the // dispinterface in the .ODL file. // {88921526-704F-11D5-860A-00104BDB8FF9} static const IID IID_IRasterBrowseDlgSink = { 0x88921526, 0x704f, 0x11d5, { 0x86, 0xa, 0x0, 0x10, 0x4b, 0xdb, 0x8f, 0xf9 } }; BEGIN_INTERFACE_MAP(CRasterBrowseDlgSink, CCmdTarget) INTERFACE_PART(CRasterBrowseDlgSink, DIID__LEADRasterThumbnailEvents, Dispatch) END_INTERFACE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRasterBrowseDlgSink message handlers void CRasterBrowseDlgSink::OnThumbnailEvent(long Bitmap, TCHAR * pszFilename, short StatusCode, short nPercent) { // theApp.m_pRasterThumbnail->ContinueBrowse = (StatusCode == 0? AfxMessageBox(pszFilename, MB_YESNO)==IDYES: TRUE); MSG msg; // are there any messages in the queue (like a key being pressed) ? while( PeekMessage(&msg,NULL, 0, 0, PM_REMOVE) ) { TranslateMessage( &msg ); /* Translates virtual key codes. */ DispatchMessage( &msg ); /* Dispatches message to window. */ } if(StatusCode == BROWSE_LOADING) //loading a file goto EVENTOUT; if ( StatusCode == SUCCESS ) { theApp.m_nBitmapsCount++ ; if ( theApp.m_nBitmapsCount >= 15) { theApp.m_nBitmapsCount-- ; return; } ILEADRaster * pRaster= NULL; HRESULT hr = CoCreateInstance( CLSID_LEADRaster, NULL, CLSCTX_ALL, IID_ILEADRaster, (void**)&pRaster); if (FAILED(hr)){theApp.DisplayLEADError(ERROR_INV_PARAMETER); return;} pRaster->Bitmap = Bitmap; if(theApp.m_DlgType == DLG_EFFECT) { theApp.m_pRasterImgEfxDlg->PutItemBitmap(theApp.m_nBitmapsCount, pRaster->GetBitmap()); theApp.m_pRasterImgEfxDlg->PutItemFileName(theApp.m_nBitmapsCount, pszFilename); theApp.m_pRasterImgEfxDlg->PutItemDescription(theApp.m_nBitmapsCount, pszFilename); } else if(theApp.m_DlgType == DLG_IMAGE) { theApp.m_pRasterImgDlg->PutItemBitmap(theApp.m_nBitmapsCount, pRaster->GetBitmap()); theApp.m_pRasterImgDlg->PutItemFileName(theApp.m_nBitmapsCount, pszFilename); theApp.m_pRasterImgDlg->PutItemDescription(theApp.m_nBitmapsCount, pszFilename); } else if(theApp.m_DlgType == DLG_COLOR) { theApp.m_pRasterClrDlg->PutItemBitmap(theApp.m_nBitmapsCount, pRaster->GetBitmap()); theApp.m_pRasterClrDlg->PutItemFileName(theApp.m_nBitmapsCount, pszFilename); theApp.m_pRasterClrDlg->PutItemDescription(theApp.m_nBitmapsCount, pszFilename); } else if(theApp.m_DlgType == DLG_FILE) { theApp.m_pRasterFileDlg->PutItemBitmap(theApp.m_nBitmapsCount, pRaster->GetBitmap()); theApp.m_pRasterFileDlg->PutItemFileName(theApp.m_nBitmapsCount, pszFilename); theApp.m_pRasterFileDlg->PutItemDescription(theApp.m_nBitmapsCount, pszFilename); } if ( pRaster ) { pRaster->Release ( ); pRaster= NULL; } } EVENTOUT: if(((CMainFrame*)theApp.m_pMainWnd)->m_bBrowseQuit) theApp.m_pRasterBrowseDlg->ContinueBrowse = FALSE; else theApp.m_pRasterBrowseDlg->ContinueBrowse = TRUE; }