home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / Maindemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-13  |  4.0 KB  |  162 lines

  1. // Maindemo.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mfcdemo.h"
  6.  
  7. #include "Maindemo.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. static UINT BASED_CODE indicators[] =
  16. {
  17.     ID_SEPARATOR,           // status line indicator
  18.     ID_INDICATOR_CAPS,
  19.     ID_INDICATOR_NUM,
  20.     ID_INDICATOR_SCRL,
  21. };
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMainFrame
  25.  
  26. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  29.     //{{AFX_MSG_MAP(CMainFrame)
  30.     ON_WM_CREATE()
  31.     ON_WM_CLOSE()
  32.     ON_WM_QUERYNEWPALETTE()
  33.     ON_WM_PALETTECHANGED()
  34.     //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CMainFrame construction/destruction
  39.  
  40. CMainFrame::CMainFrame()
  41. {
  42.     // TODO: add member initialization code here
  43.     
  44. }
  45.  
  46. CMainFrame::~CMainFrame()
  47. {
  48. }
  49.  
  50. static const WCHAR BASED_CODE _szLicString[] =
  51.     L"LEADTOOLS OCX Copyright (c) 1998 LEAD Technologies, Inc.";
  52.  
  53. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  54. {
  55.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  56.         return -1;
  57.     
  58.     if (!m_wndToolBar.Create(this) ||
  59.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  60.     {
  61.         TRACE0("Failed to create toolbar\n");
  62.         return -1;      // fail to create
  63.     }
  64.  
  65.     if (!m_wndStatusBar.Create(this) ||
  66.         !m_wndStatusBar.SetIndicators(indicators,
  67.           sizeof(indicators)/sizeof(UINT)))
  68.     {
  69.         TRACE0("Failed to create status bar\n");
  70.         return -1;      // fail to create
  71.     }
  72.  
  73.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  74.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  75.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  76.  
  77.     // TODO: Delete these three lines if you don't want the toolbar to
  78.     //  be dockable
  79.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  80.     EnableDocking(CBRS_ALIGN_ANY);
  81.     DockControlBar(&m_wndToolBar);
  82.  
  83.     m_pLead = new CLead;
  84.    // pass the license string to the CLead::Create function.
  85.     // The CLead::Create expects a BSTR parameter and SysAllocString converts the
  86.     //    WCHAR[] to a BSTR
  87.     BSTR lpLic = SysAllocString(_szLicString);
  88.      m_pLead->Create("", 0,CRect(0,0,50,50),this,0,NULL,FALSE,lpLic);
  89.     m_pLead->ShowWindow(SW_HIDE);
  90.     SysFreeString(lpLic);
  91.  
  92.     UNLOCKSUPPORT(*m_pLead); // Unlock support for the LZW files and express capabilities
  93.  
  94. #ifndef _ALPHA_
  95.     m_pLTIsis = new CLeadIsis;
  96.     m_pLTIsis->Create(NULL,0,CRect(0,0,1,1),this,100);
  97. #endif
  98.  
  99.     return 0;
  100. }
  101.  
  102. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  103. {
  104.     // TODO: Modify the Window class or styles here by modifying
  105.     //  the CREATESTRUCT cs
  106.  
  107.     return CMDIFrameWnd::PreCreateWindow(cs);
  108. }
  109.  
  110. /////////////////////////////////////////////////////////////////////////////
  111. // CMainFrame diagnostics
  112.  
  113. #ifdef _DEBUG
  114. void CMainFrame::AssertValid() const
  115. {
  116.     CMDIFrameWnd::AssertValid();
  117. }
  118.  
  119. void CMainFrame::Dump(CDumpContext& dc) const
  120. {
  121.     CMDIFrameWnd::Dump(dc);
  122. }
  123.  
  124. #endif //_DEBUG
  125.  
  126. /////////////////////////////////////////////////////////////////////////////
  127. // CMainFrame message handlers
  128. BOOL CMainFrame::OnQueryNewPalette() 
  129. {
  130.     // always realize the palette for the active view
  131.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  132.     if (pMDIChildWnd == NULL)
  133.         return FALSE; // no active MDI child frame (no new palette)
  134.     CView* pView = pMDIChildWnd->GetActiveView();
  135.     ASSERT(pView != NULL);
  136.  
  137.     // just notify the target view
  138.     return((BOOL) pView->SendMessage(WM_DOREALIZE, (WPARAM)m_hWnd, (LPARAM) FALSE));
  139. }
  140.  
  141. void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) 
  142. {
  143.     CMDIFrameWnd::OnPaletteChanged(pFocusWnd);
  144.  
  145.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  146.     if (pMDIChildWnd == NULL)
  147.         return; // no active MDI child frame
  148.  
  149.     SendMessageToDescendants(WM_DOREALIZE, (WPARAM)pFocusWnd->m_hWnd, (LPARAM) TRUE);
  150. }
  151.  
  152. void CMainFrame::OnClose() 
  153. {
  154.     m_pLead->DestroyWindow();
  155.     delete m_pLead;
  156. #ifndef _ALPHA_
  157.     delete m_pLTIsis;
  158. #endif
  159.     
  160.     CMDIFrameWnd::OnClose();
  161. }
  162.