home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch09 / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-13  |  2.7 KB  |  116 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "autoclik.h"
  6.  
  7. #include "mainfrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char BASED_CODE THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMainFrame
  16.  
  17. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  18.  
  19. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  20.     //{{AFX_MSG_MAP(CMainFrame)
  21.         // NOTE - the ClassWizard will add and remove mapping macros here.
  22.         //    DO NOT EDIT what you see in these blocks of generated code !
  23.     ON_WM_CREATE()
  24.     //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // arrays of IDs used to initialize control bars
  29.  
  30. // toolbar buttons - IDs are command buttons
  31. static UINT BASED_CODE buttons[] =
  32. {
  33.     // same order as in the bitmap 'toolbar.bmp'
  34.     ID_FILE_NEW,
  35.     ID_FILE_OPEN,
  36.     ID_FILE_SAVE,
  37.         ID_SEPARATOR,
  38.     ID_EDIT_CUT,
  39.     ID_EDIT_COPY,
  40.     ID_EDIT_PASTE,
  41.         ID_SEPARATOR,
  42.     ID_FILE_PRINT,
  43.     ID_APP_ABOUT,
  44. };
  45.  
  46. static UINT BASED_CODE indicators[] =
  47. {
  48.     ID_SEPARATOR,           // status line indicator
  49.     ID_INDICATOR_CAPS,
  50.     ID_INDICATOR_NUM,
  51.     ID_INDICATOR_SCRL,
  52. };
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CMainFrame construction/destruction
  56.  
  57. CMainFrame::CMainFrame()
  58. {
  59.     // TODO: add member initialization code here
  60. }
  61.  
  62. CMainFrame::~CMainFrame()
  63. {
  64. }
  65.  
  66. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  67. {
  68.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  69.         return -1;
  70.  
  71.     if (!m_wndToolBar.Create(this,
  72.           WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY) ||
  73.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  74.         !m_wndToolBar.SetButtons(buttons,
  75.           sizeof(buttons)/sizeof(UINT)))
  76.     {
  77.         TRACE0("Failed to create toolbar\n");
  78.         return -1;      // fail to create
  79.     }
  80.  
  81.     if (!m_wndStatusBar.Create(this) ||
  82.         !m_wndStatusBar.SetIndicators(indicators,
  83.           sizeof(indicators)/sizeof(UINT)))
  84.     {
  85.         TRACE0("Failed to create status bar\n");
  86.         return -1;      // fail to create
  87.     }
  88.  
  89.     // TODO: Delete these three lines if you don't want the toolbar to
  90.     //  be dockable
  91.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  92.     EnableDocking(CBRS_ALIGN_ANY);
  93.     DockControlBar(&m_wndToolBar);
  94.  
  95.     return 0;
  96. }
  97.  
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CMainFrame diagnostics
  100.  
  101. #ifdef _DEBUG
  102. void CMainFrame::AssertValid() const
  103. {
  104.     CMDIFrameWnd::AssertValid();
  105. }
  106.  
  107. void CMainFrame::Dump(CDumpContext& dc) const
  108. {
  109.     CMDIFrameWnd::Dump(dc);
  110. }
  111.  
  112. #endif //_DEBUG
  113.  
  114. /////////////////////////////////////////////////////////////////////////////
  115. // CMainFrame message handlers
  116.