// TwainDemoView.cpp : implementation of the CTwainDemoView class // #include "stdafx.h" #include "TwainDemo.h" #include "TwainDemoDoc.h" #include "TwainDemoView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CTwainDemoView IMPLEMENT_DYNCREATE(CTwainDemoView, CView) BEGIN_MESSAGE_MAP(CTwainDemoView, CView) //{{AFX_MSG_MAP(CTwainDemoView) ON_WM_CREATE() ON_COMMAND(ID_FILE_SAVE, OnFileSave) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTwainDemoView construction/destruction CTwainDemoView::CTwainDemoView() { // TODO: add construction code here } CTwainDemoView::~CTwainDemoView() { } BOOL CTwainDemoView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CTwainDemoView drawing void CTwainDemoView::OnDraw(CDC* pDC) { CTwainDemoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CTwainDemoView printing BOOL CTwainDemoView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CTwainDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CTwainDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CTwainDemoView diagnostics #ifdef _DEBUG void CTwainDemoView::AssertValid() const { CView::AssertValid(); } void CTwainDemoView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CTwainDemoDoc* CTwainDemoView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTwainDemoDoc))); return (CTwainDemoDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CTwainDemoView message handlers void CTwainDemoView::OnInitialUpdate() { m_LeadBmpWnd.EnableKeyBoard(FALSE); m_LeadBmpWnd.EnableCenterOnZoom(FALSE); CView::OnInitialUpdate(); } int CTwainDemoView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; if (m_LeadBmpWnd.SetWndHandle(GetSafeHwnd()) != SUCCESS) { LBase::DisplayErrorFromList(GetSafeHwnd()); return -1; } return 0; } void CTwainDemoView::OnFileSave() { BeginWaitCursor(); L_BOOL bOldAutoProcess=FALSE; SAVEDLGPARAMS SaveParms; bOldAutoProcess = m_LeadBmpWnd.DialogFile()->IsAutoProcessEnabled(); m_LeadBmpWnd.DialogFile()->EnableAutoProcess(); memset(&SaveParms, 0, sizeof(SAVEDLGPARAMS)); SaveParms.uStructSize = sizeof(SAVEDLGPARAMS); SaveParms.pBitmap = m_LeadBmpWnd.GetHandle(); SaveParms.nBitsPerPixel = m_LeadBmpWnd.GetBitsPerPixel(); SaveParms.nFormat = FILE_BMP; SaveParms.nQFactor = 2; SaveParms.nStampBits = 24; SaveParms.nStampWidth = 120; SaveParms.nStampHeight = 120; SaveParms.uSaveMulti = MULTIPAGE_OPERATION_REPLACE; SaveParms.uDlgFlags = DLG_SAVE_SHOW_FILEOPTIONS_PROGRESSIVE | DLG_SAVE_SHOW_FILEOPTIONS_MULTIPAGE | DLG_SAVE_SHOW_FILEOPTIONS_STAMP | DLG_SAVE_SHOW_FILEOPTIONS_QFACTOR | DLG_SAVE_SHOW_FILEOPTIONS_J2KOPTIONS | DLG_SAVE_SHOW_FILEOPTIONS_BASICJ2KOPTIONS; m_LeadBmpWnd.DialogFile()->SetSaveParams(&SaveParms); L_INT nRet = m_LeadBmpWnd.DialogFile()->DoModalSave(GetSafeHwnd()); if ((nRet != SUCCESS_DLG_OK) && (nRet != SUCCESS_DLG_CANCEL)) LBase::DisplayErrorFromList(GetSafeHwnd()); m_LeadBmpWnd.DialogFile()->EnableAutoProcess(bOldAutoProcess); EndWaitCursor(); }