home *** CD-ROM | disk | FTP | other *** search
/ C/C++ User's Journal & Wi…eveloper's Journal Tools / C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso / stingray / mainfrm.cpp < prev    next >
C/C++ Source or Header  |  1996-10-27  |  3KB  |  147 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. // This is a part of the Objective Grid C++ Library.
  5. // Copyright (C) 1995,1996 ClassWorks, Stefan Hoenig.
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to
  9. // the Objective Grid Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding
  12. // the Objective Grid product.
  13. //
  14.  
  15. #include "stdafx.h"
  16. #include "gridapp.h"
  17.  
  18. #include "mainfrm.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. IMPLEMENT_DYNAMIC(CMainFrame, CGridMDIFrameWnd)
  26.  
  27. #define new DEBUG_NEW
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CMainFrame
  31.  
  32. BEGIN_MESSAGE_MAP(CMainFrame, CGridMDIFrameWnd)
  33.     //{{AFX_MSG_MAP(CMainFrame)
  34.     ON_WM_CREATE()
  35.     //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // arrays of IDs used to initialize control bars
  40.  
  41. // toolbar buttons - IDs are command buttons
  42. static UINT BASED_CODE buttons[] =
  43. {
  44.     // same order as in the bitmap 'toolbar.bmp'
  45.     ID_FILE_NEW,
  46.     ID_FILE_OPEN,
  47.     ID_FILE_SAVE,
  48.         ID_SEPARATOR,
  49.     ID_EDIT_CUT,
  50.     ID_EDIT_COPY,
  51.     ID_EDIT_PASTE,
  52.         ID_SEPARATOR,
  53.     ID_FILE_PRINT,
  54.         ID_SEPARATOR,
  55.     ID_EDIT_UNDO,
  56.     ID_EDIT_REDO,
  57.         ID_SEPARATOR,
  58.     ID_VIEW_ZOOMIN,
  59.     ID_VIEW_ZOOMOUT,
  60.     ID_VIEW_100,
  61.         ID_SEPARATOR,
  62.     ID_FORMAT_ALIGN_LEFT,
  63.     ID_FORMAT_ALIGN_CENTER,
  64.     ID_FORMAT_ALIGN_RIGHT,
  65.         ID_SEPARATOR,
  66.     ID_FORMAT_STYLE_BOLD,
  67.     ID_FORMAT_STYLE_ITALIC,
  68.     ID_FORMAT_STYLE_UNDERLINE,
  69.         ID_SEPARATOR,
  70.     ID_APP_ABOUT,
  71. };
  72.  
  73. static UINT BASED_CODE indicators[] =
  74. {
  75.     ID_SEPARATOR,           // status line indicator
  76.     ID_INDICATOR_CAPS,
  77.     ID_INDICATOR_NUM,
  78.     ID_INDICATOR_SCRL,
  79. };
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CMainFrame construction/destruction
  83.  
  84. CMainFrame::CMainFrame()
  85. {
  86.     // TODO: add member initialization code here
  87. }
  88.  
  89. CMainFrame::~CMainFrame()
  90. {
  91. }
  92.  
  93. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  94. {
  95.     if (CGridMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  96.         return -1;
  97.  
  98.     if (!m_wndToolBar.Create(this) ||
  99.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  100.         !m_wndToolBar.SetButtons(buttons,
  101.           sizeof(buttons)/sizeof(UINT)))
  102.     {
  103.         TRACE0("Failed to create toolbar\n");
  104.         return -1;      // fail to create
  105.     }
  106.  
  107.     if (!m_wndStatusBar.Create(this) ||
  108.         !m_wndStatusBar.SetIndicators(indicators,
  109.           sizeof(indicators)/sizeof(UINT)))
  110.     {
  111.         TRACE0("Failed to create status bar\n");
  112.         return -1;      // fail to create
  113.     }
  114.  
  115. #if _MFC_VER >= 0x0300
  116.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  117.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  118.         CBRS_TOOLTIPS | CBRS_FLYBY);
  119.  
  120.     EnableDocking(CBRS_ALIGN_ANY);
  121.     DockControlBar(&m_wndToolBar);
  122. #endif
  123.  
  124.     return 0;
  125. }
  126.  
  127.  
  128. /////////////////////////////////////////////////////////////////////////////
  129. // CMainFrame diagnostics
  130.  
  131. #ifdef _DEBUG
  132. void CMainFrame::AssertValid() const
  133. {
  134.     CGridMDIFrameWnd::AssertValid();
  135. }
  136.  
  137. void CMainFrame::Dump(CDumpContext& dc) const
  138. {
  139.     CGridMDIFrameWnd::Dump(dc);
  140. }
  141.  
  142. #endif //_DEBUG
  143.  
  144. /////////////////////////////////////////////////////////////////////////////
  145. // CMainFrame message handlers
  146.  
  147.