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

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