home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / MAINMAGN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-10  |  3.1 KB  |  131 lines

  1. // Mainmagn.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "magnify.h"
  6.  
  7. #include "Mainmagn.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMainFrame
  17.  
  18. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  19.  
  20. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  21.     ON_WM_CREATE()
  22.     ON_WM_QUERYNEWPALETTE()
  23.     ON_WM_PALETTECHANGED()
  24.     //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26.  
  27. static UINT indicators[] =
  28. {
  29.     ID_SEPARATOR,           // status line indicator
  30.     ID_INDICATOR_CAPS,
  31.     ID_INDICATOR_NUM,
  32.     ID_INDICATOR_SCRL,
  33. };
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CMainFrame construction/destruction
  37.  
  38. CMainFrame::CMainFrame()
  39. {
  40.     // TODO: add member initialization code here
  41.     
  42. }
  43.  
  44. CMainFrame::~CMainFrame()
  45. {
  46. }
  47.  
  48. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  49. {
  50.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  51.         return -1;
  52.     
  53.     if (!m_wndToolBar.Create(this) ||
  54.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  55.     {
  56.         TRACE0("Failed to create toolbar\n");
  57.         return -1;      // fail to create
  58.     }
  59.  
  60.     if (!m_wndStatusBar.Create(this) ||
  61.         !m_wndStatusBar.SetIndicators(indicators,
  62.           sizeof(indicators)/sizeof(UINT)))
  63.     {
  64.         TRACE0("Failed to create status bar\n");
  65.         return -1;      // fail to create
  66.     }
  67.  
  68.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  69.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  70.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  71.  
  72.     // TODO: Delete these three lines if you don't want the toolbar to
  73.     //  be dockable
  74.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  75.     EnableDocking(CBRS_ALIGN_ANY);
  76.     DockControlBar(&m_wndToolBar);
  77.  
  78.     return 0;
  79. }
  80.  
  81. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  82. {
  83.     // TODO: Modify the Window class or styles here by modifying
  84.     //  the CREATESTRUCT cs
  85.  
  86.     return CMDIFrameWnd::PreCreateWindow(cs);
  87. }
  88.  
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CMainFrame diagnostics
  91.  
  92. #ifdef _DEBUG
  93. void CMainFrame::AssertValid() const
  94. {
  95.     CMDIFrameWnd::AssertValid();
  96. }
  97.  
  98. void CMainFrame::Dump(CDumpContext& dc) const
  99. {
  100.     CMDIFrameWnd::Dump(dc);
  101. }
  102.  
  103. #endif //_DEBUG
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CMainFrame message handlers
  107. BOOL CMainFrame::OnQueryNewPalette() 
  108. {
  109.     // always realize the palette for the active view
  110.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  111.     if (pMDIChildWnd == NULL)
  112.         return FALSE; // no active MDI child frame (no new palette)
  113.     CView* pView = pMDIChildWnd->GetActiveView();
  114.     ASSERT(pView != NULL);
  115.  
  116.     // just notify the target view
  117.     return((BOOL) pView->SendMessage(WM_DOREALIZE, (WPARAM)m_hWnd, (LPARAM) FALSE));
  118. }
  119.  
  120. void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) 
  121. {
  122.     CMDIFrameWnd::OnPaletteChanged(pFocusWnd);
  123.  
  124.     CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  125.     if (pMDIChildWnd == NULL)
  126.         return; // no active MDI child frame
  127.  
  128.     SendMessageToDescendants(WM_DOREALIZE, (WPARAM)pFocusWnd->m_hWnd, (LPARAM) TRUE);
  129. }
  130.  
  131.