/*[]=====================================================================[]*/ /*[] LEADTOOLS for Windows(Class Library) - Version 11 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2000 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ /*---(StampGet)------------------------------------------------------------ We have made the assumption that the user has the knowledge of Object Oriented programing of C under Windows. This example will: 1. load a stamp from a file, selected using Windows' common dialog box for opening a file, to a bitmap, 2. display the image in a window. Usage: STAMPGET --------------------------------------------------------------------------*/ // GetStpVw.cpp : implementation of the CGetStampView class // #include "stdafx.h" #include "GetStamp.h" #include "GtStpDoc.h" #include "GetStpVw.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGetStampView IMPLEMENT_DYNCREATE(CGetStampView, CView) BEGIN_MESSAGE_MAP(CGetStampView, CView) //{{AFX_MSG_MAP(CGetStampView) ON_WM_CREATE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGetStampView construction/destruction CGetStampView::CGetStampView() { // TODO: add construction code here } CGetStampView::~CGetStampView() { } ///////////////////////////////////////////////////////////////////////////// // CGetStampView drawing void CGetStampView::OnDraw(CDC* pDC) { CGetStampDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CGetStampView diagnostics #ifdef _DEBUG void CGetStampView::AssertValid() const { CView::AssertValid(); } void CGetStampView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CGetStampDoc* CGetStampView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGetStampDoc))); return (CGetStampDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CGetStampView message handlers int CGetStampView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized code here and/or call the base class m_LBitmapWnd.SetWndHandle(GetSafeHwnd()); return 0; } void CGetStampView::OnInitialUpdate() { CView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class AfxGetMainWnd()->SetWindowText(_T("Class Library Get Stamp Demo (32 Bit Version)")); OPENDLGPARAMS FOParm ; OPENFILENAME OpenFileName; memset ( &FOParm, 0, sizeof(OPENDLGPARAMS)) ; memset ( &OpenFileName, 0, sizeof(OPENFILENAME)) ; OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.lpstrInitialDir = NULL; OpenFileName.Flags = OFN_EXPLORER; FOParm.uStructSize = sizeof(OPENDLGPARAMS); FOParm.uDlgFlags = DLG_OPEN_SHOW_PROGRESSIVE | DLG_OPEN_SHOW_MULTIPAGE | DLG_OPEN_SHOW_LOADROTATED | DLG_OPEN_SHOW_LOADCOMPRESSED | DLG_OPEN_SHOW_FILEINFO | DLG_OPEN_SHOW_DELPAGE | DLG_OPEN_VIEWTOTALPAGES ; m_LBitmapWnd.DialogFile()->SetOpenParams(&FOParm) ; m_LBitmapWnd.DialogFile()->SetOpenFileName(&OpenFileName) ; m_LBitmapWnd.DialogFile()->EnablePreview(TRUE); L_INT nRet = m_LBitmapWnd.DialogFile()->DoModalOpen(AfxGetMainWnd()->m_hWnd); if (nRet != SUCCESS_DLG_OK) { LBase::DisplayError(m_hWnd, nRet); AfxGetMainWnd()->PostMessage(WM_CLOSE); return ; /* Failure in creation, so return . */ } nRet = m_LBitmapWnd.File()->ReadStamp(); if ( nRet != SUCCESS ) { LBase::DisplayError(m_hWnd, nRet); AfxGetMainWnd()->PostMessage(WM_CLOSE); return ; } } void CGetStampView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd(); // TODO: Add your specialized code here and/or call the base class if(bActivate==TRUE&&pActivateView==this) m_LBitmapWnd.HandlePalette(WM_QUERYNEWPALETTE, 0, 0); CView::OnActivateView(bActivate, pActivateView, pDeactiveView); }