// ScrView.cpp : implementation of the CScrView class // #include "stdafx.h" #include "ScrDemo.h" #include "ScrDoc.h" #include "ScrView.h" #include "..\\..\\..\\..\\include\\l_ocx40.h" //#include "..\\..\\..\\..\\include\\ltdlgocx.h" //#include "leaddlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CScrDemo theApp; ///////////////////////////////////////////////////////////////////////////// // CScrView IMPLEMENT_DYNCREATE(CScrView, CView) BEGIN_MESSAGE_MAP(CScrView, CView) //{{AFX_MSG_MAP(CScrView) // ON_COMMAND(IDM_CAPTURE_FROMEXEDLGTABBEDVIEW, OnCaptureFromexedlgtabbedview) // ON_COMMAND(IDM_CAPTURE_FULLSCREEN, OnCaptureFullscreen) // ON_COMMAND(IDM_CAPTURE_MOUSECURSOR, OnCaptureMousecursor) // ON_COMMAND(IDM_CAPTURE_SELECTEDOBJECT, OnCaptureSelectedobject) // ON_COMMAND(IDM_CAPTURE_WINDOWUNDERCURSOR, OnCaptureWindowundercursor) // ON_COMMAND(IDM_OPTIONS_OBJECT, OnOptionsObject) ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs) ON_WM_SIZE() ON_WM_CREATE() //}}AFX_MSG_MAP // Standard printing commands ON_MESSAGE(WM_DOREALIZE, OnDoRealize) ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CScrView construction/destruction CScrView::CScrView() { // TODO: add construction code here theApp.m_pRasterFileDlg->put_Bitmap(0); } CScrView::~CScrView() { } BOOL CScrView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CScrView drawing void CScrView::OnDraw(CDC* pDC) { CScrDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CScrView printing BOOL CScrView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CScrView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CScrView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CScrView diagnostics #ifdef _DEBUG void CScrView::AssertValid() const { CView::AssertValid(); } void CScrView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CScrDoc* CScrView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CScrDoc))); return (CScrDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CScrView message handlers void CScrView::OnFileSaveAs() { int nRet; char szDir[300]; GetCurrentDirectory(sizeof(szDir),szDir); theApp.m_pRasterFileDlg->PutBitmap(m_LeadBitmap.GetBitmap()); theApp.m_pRasterFileDlg->PutDialogTitle("Save File"); theApp.m_pRasterFileDlg->PutFileDlgFlags(0); theApp.m_pRasterFileDlg->PutInitialDir(szDir); theApp.m_pRasterFileDlg->PutUIFlags( SAVE_AUTOPROCESS | SAVE_SHOW_FILEOPTIONS_MULTIPAGE | SAVE_SHOW_FILEOPTIONS_PROGRESSIVE | SAVE_SHOW_FILEOPTIONS_QFACTOR| SAVE_SHOW_FILEOPTIONS_STAMP | SAVE_SHOW_FILEOPTIONS_BASICJ2KOPTIONS| SAVE_SHOW_FILEOPTIONS_J2KOPTIONS); nRet= theApp.m_pRasterFileDlg->ShowSaveDlg((long)this->m_hWnd); if(nRet !=0) { CString str; str.Format("A LEADTOOLS error has occured.\nCODE = %d", nRet); MessageBox(str); return; } } void CScrView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); // TODO: Add your message handler code here if (m_LeadBitmap.GetBitmap()) m_LeadBitmap.MoveWindow(0,0,cx,cy); } int CScrView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here if (theApp.m_LeadBitmap) { m_LeadBitmap.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,0x100); m_LeadBitmap.SetBitmap((long)theApp.m_LeadBitmap); UNLOCKSUPPORT(m_LeadBitmap); if (m_LeadBitmap.GetBitmap()) if (m_LeadBitmap.GetHasRgn()) { m_LeadBitmap.SetRgnFrameType(2/*CLead::RGNFRAME_ANIMATED*/); } } return 0; } LRESULT CScrView::OnDoRealize(WPARAM wParam, LPARAM lParam) { if( !IsWindow(m_LeadBitmap.m_hWnd) || !m_LeadBitmap.GetBitmap() ) return FALSE; if(lParam) { return m_LeadBitmap.SendMessage(WM_PALETTECHANGED, wParam); } else { return m_LeadBitmap.SendMessage(WM_QUERYNEWPALETTE,0); } } void CScrView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { if (bActivate) { ASSERT(pActivateView == this); OnDoRealize((WPARAM)theApp.m_pMainWnd->m_hWnd, (LPARAM) FALSE); } CView::OnActivateView(bActivate, pActivateView, pDeactiveView); }