home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / Scrview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-02  |  4.4 KB  |  176 lines

  1. // ScrView.cpp : implementation of the CScrView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ScrDemo.h"
  6. #include "ScrDoc.h"
  7. #include "ScrView.h"
  8.  
  9. #include "..\\..\\..\\..\\include\\ltdlgocx.h"
  10. #include "leaddlg.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. extern CScrDemo theApp;
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CScrView
  21.  
  22. IMPLEMENT_DYNCREATE(CScrView, CView)
  23.  
  24. BEGIN_MESSAGE_MAP(CScrView, CView)
  25.     //{{AFX_MSG_MAP(CScrView)
  26. //    ON_COMMAND(IDM_CAPTURE_FROMEXEDLGTABBEDVIEW, OnCaptureFromexedlgtabbedview)
  27. //    ON_COMMAND(IDM_CAPTURE_FULLSCREEN, OnCaptureFullscreen)
  28. //    ON_COMMAND(IDM_CAPTURE_MOUSECURSOR, OnCaptureMousecursor)
  29. //    ON_COMMAND(IDM_CAPTURE_SELECTEDOBJECT, OnCaptureSelectedobject)
  30. //    ON_COMMAND(IDM_CAPTURE_WINDOWUNDERCURSOR, OnCaptureWindowundercursor)
  31. //    ON_COMMAND(IDM_OPTIONS_OBJECT, OnOptionsObject)
  32.     ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
  33.     ON_WM_SIZE()
  34.     ON_WM_CREATE()
  35.     //}}AFX_MSG_MAP
  36.     // Standard printing commands
  37.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  38.     ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  39.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CScrView construction/destruction
  44.  
  45. CScrView::CScrView()
  46. {
  47.     // TODO: add construction code here
  48.  
  49. }
  50.  
  51. CScrView::~CScrView()
  52. {
  53. }
  54.  
  55. BOOL CScrView::PreCreateWindow(CREATESTRUCT& cs)
  56. {
  57.     // TODO: Modify the Window class or styles here by modifying
  58.     //  the CREATESTRUCT cs
  59.  
  60.     return CView::PreCreateWindow(cs);
  61. }
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CScrView drawing
  65.  
  66. void CScrView::OnDraw(CDC* pDC)
  67. {
  68.     CScrDoc* pDoc = GetDocument();
  69.     ASSERT_VALID(pDoc);
  70.  
  71.     // TODO: add draw code for native data here
  72. }
  73.  
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CScrView printing
  76.  
  77. BOOL CScrView::OnPreparePrinting(CPrintInfo* pInfo)
  78. {
  79.     // default preparation
  80.     return DoPreparePrinting(pInfo);
  81. }
  82.  
  83. void CScrView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  84. {
  85.     // TODO: add extra initialization before printing
  86. }
  87.  
  88. void CScrView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  89. {
  90.     // TODO: add cleanup after printing
  91. }
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CScrView diagnostics
  95.  
  96. #ifdef _DEBUG
  97. void CScrView::AssertValid() const
  98. {
  99.     CView::AssertValid();
  100. }
  101.  
  102. void CScrView::Dump(CDumpContext& dc) const
  103. {
  104.     CView::Dump(dc);
  105. }
  106.  
  107. CScrDoc* CScrView::GetDocument() // non-debug version is inline
  108. {
  109.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CScrDoc)));
  110.     return (CScrDoc*)m_pDocument;
  111. }
  112. #endif //_DEBUG
  113.  
  114. /////////////////////////////////////////////////////////////////////////////
  115. // CScrView message handlers
  116.  
  117. void CScrView::OnFileSaveAs() 
  118. {
  119.     // TODO: Add your command handler code here
  120.    CLeadDlg m_LEADDlg1;
  121.    char     szDir[300];
  122.  
  123.  
  124.    GetCurrentDirectory(sizeof(szDir),szDir);
  125.    if(m_LEADDlg1.Create(NULL,0,CRect(0,0,0,0),this,0))
  126.    {
  127.        m_LEADDlg1.SetEnableMethodErrors(FALSE);
  128.        m_LEADDlg1.SetBitmap(m_LeadBitmap.GetBitmap()); //assign the bitmap for processing
  129.        m_LEADDlg1.SetDialogTitle("Save A File");
  130.        m_LEADDlg1.SetFileDlgFlags(OFN_CREATEPROMPT);
  131.        m_LEADDlg1.SetInitialDir(szDir);
  132.        m_LEADDlg1.SetUIFlags( DLG_FS_AUTOPROCESS |
  133.                               DLG_FS_95STYLE |
  134.                               DLG_FS_PROGRESSIVE |
  135.                               DLG_FS_MULTIPAGE |
  136.                               DLG_FS_STAMP |
  137.                               DLG_FS_QFACTOR );
  138.        m_LEADDlg1.SetSaveFormatFlags(DLG_FS_ALL);
  139.        m_LEADDlg1.FileSave((long)m_hWnd);
  140.        GetDocument()->SetModifiedFlag (FALSE);
  141.    }
  142.     
  143. }
  144.  
  145. void CScrView::OnSize(UINT nType, int cx, int cy) 
  146. {
  147.     CView::OnSize(nType, cx, cy);
  148.     // TODO: Add your message handler code here
  149.     if (m_LeadBitmap.GetBitmap())
  150.         m_LeadBitmap.MoveWindow(0,0,cx,cy);
  151.     
  152. }
  153.  
  154. int CScrView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  155. {
  156.     if (CView::OnCreate(lpCreateStruct) == -1)
  157.         return -1;
  158.     
  159.     // TODO: Add your specialized creation code here
  160.     
  161.     if (theApp.m_LeadBitmap)
  162.     {
  163.         m_LeadBitmap.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,0x100);
  164.         m_LeadBitmap.SetBitmap((long)theApp.m_LeadBitmap);        
  165. //        UNLOCKSUPPORT(m_LeadBitmap);
  166.         if (m_LeadBitmap.GetBitmap())
  167.             if (m_LeadBitmap.GetHasRgn())
  168.             {
  169.                 m_LeadBitmap.SetRgnFrameType(2/*CLead::RGNFRAME_ANIMATED*/);
  170.             }
  171.         
  172.     }
  173.     
  174.     return 0;
  175. }
  176.