// RasterProcSink.cpp : implementation file // #include "stdafx.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CIMGPFApp theApp; ///////////////////////////////////////////////////////////////////////////// // CRasterProcSink IMPLEMENT_DYNCREATE(CRasterProcSink, CCmdTarget) CRasterProcSink::CRasterProcSink() { EnableAutomation(); } CRasterProcSink::~CRasterProcSink() { } void CRasterProcSink::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(CRasterProcSink, CCmdTarget) //{{AFX_MSG_MAP(CRasterProcSink) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DISPATCH_MAP(CRasterProcSink, CCmdTarget) //{{AFX_DISPATCH_MAP(CRasterProcSink) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_DISPATCH_MAP DISP_FUNCTION_ID(CRasterProcSink,"ProgressStatus",1,OnProgressStatus,VT_I2,VTS_I2) END_DISPATCH_MAP() // Note: we add support for IID_IRasterProcSink to support typesafe binding // from VBA. This IID must match the GUID that is attached to the // dispinterface in the .ODL file. // {FCEC20F1-6B67-4CFC-A652-C2ABCCFC8A8C} static const IID IID_IRasterProcSink = { 0xfcec20f1, 0x6b67, 0x4cfc, { 0xa6, 0x52, 0xc2, 0xab, 0xcc, 0xfc, 0x8a, 0x8c } }; BEGIN_INTERFACE_MAP(CRasterProcSink, CCmdTarget) INTERFACE_PART(CRasterProcSink, DIID__LEADRasterProcessEvents, Dispatch) END_INTERFACE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRasterProcSink message handlers int CRasterProcSink::OnProgressStatus(short iPercent) { MSG msg; CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd(); if (!pFrame) return 0; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CIMGPFView *pView = (CIMGPFView *) pChild->GetActiveView(); if(pView->m_pKfmnDlg) { pView->m_pKfmnDlg->m_progress.SetPos(iPercent); if(iPercent == 100) pView->m_pKfmnDlg->m_progress.SetPos(0); if(pView->m_pKfmnDlg->m_bKillProgress) return ERROR_USER_ABORT; } else { BeginWaitCursor(); pFrame->m_bInProcess = TRUE; pFrame->m_wndStatusBar.SetPaneText( 1, TEXT("Press ESC to cancel"), TRUE); pFrame->m_Progress.SetPos( iPercent ); if (iPercent == 100) { pFrame->m_Progress.SetPos( 0 ); pFrame->m_wndStatusBar.SetPaneText( 1, TEXT(""), TRUE); } if (pFrame->m_bAbortProcess) { pFrame->m_Progress.SetPos( 0 ); pFrame->m_wndStatusBar.SetPaneText( 1, TEXT(""), TRUE); pFrame->m_bInProcess = FALSE; pFrame->m_bAbortProcess = FALSE; theApp.m_pRasterProcess->PutEnableProgressEvent( FALSE ); EndWaitCursor(); return ERROR_USER_ABORT; } if (PeekMessage (&msg, AfxGetApp()->GetMainWnd()->m_hWnd, 0, 0, PM_REMOVE)) { if (msg.message == WM_KEYDOWN) { TranslateMessage (&msg); DispatchMessage (&msg); } } EndWaitCursor(); } return 0; }