home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / dbvlist / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.2 KB  |  133 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "DBVList.h"
  15. #include "DBVListSet.h"
  16. #include "DBVListDoc.h"
  17. #include "DBVListView.h"
  18.  
  19. #include "MainFrm.h"
  20. #include "EmpView.h"
  21.  
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CMainFrame
  30.  
  31. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  32.  
  33. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  34.     //{{AFX_MSG_MAP(CMainFrame)
  35.     ON_WM_CREATE()
  36.     //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38.  
  39. static UINT indicators[] =
  40. {
  41.     ID_SEPARATOR,           // status line indicator
  42.     ID_INDICATOR_CAPS,
  43.     ID_INDICATOR_NUM,
  44.     ID_INDICATOR_SCRL,
  45. };
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CMainFrame construction/destruction
  49.  
  50. CMainFrame::CMainFrame()
  51. {
  52. }
  53.  
  54. CMainFrame::~CMainFrame()
  55. {
  56. }
  57.  
  58. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  59. {
  60.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  61.         return -1;
  62.  
  63.     if (!m_wndToolBar.Create(this) ||
  64.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  65.     {
  66.         TRACE0("Failed to create toolbar\n");
  67.         return -1;      // fail to create
  68.     }
  69.  
  70.     if (!m_wndStatusBar.Create(this) ||
  71.         !m_wndStatusBar.SetIndicators(indicators,
  72.           sizeof(indicators)/sizeof(UINT)))
  73.     {
  74.         TRACE0("Failed to create status bar\n");
  75.         return -1;      // fail to create
  76.     }
  77.  
  78.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  79.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  80.  
  81.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  82.     EnableDocking(CBRS_ALIGN_ANY);
  83.     DockControlBar(&m_wndToolBar);
  84.  
  85.     return 0;
  86. }
  87.  
  88. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  89.     CCreateContext* pContext)
  90. {
  91.         if (!m_wndSplitter.CreateStatic(this,2,1))
  92.         {
  93.             TRACE0("Failed to create split bar ");
  94.             return FALSE;    // failed to create
  95.         }
  96.         if(!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CDBVListView),CSize(10,200),pContext))
  97.         {
  98.             TRACE0("Failed to create CDBVListView ");
  99.             return FALSE;    // failed to create
  100.         }
  101.         if(!m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CEmpView),CSize(10,100),pContext))
  102.         {
  103.             TRACE0("Failed to create CEmpView ");
  104.             return FALSE;    // failed to create
  105.         }
  106.  
  107.         return TRUE;
  108. }
  109.  
  110. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  111. {
  112.     return CFrameWnd::PreCreateWindow(cs);
  113. }
  114.  
  115. /////////////////////////////////////////////////////////////////////////////
  116. // CMainFrame diagnostics
  117.  
  118. #ifdef _DEBUG
  119. void CMainFrame::AssertValid() const
  120. {
  121.     CFrameWnd::AssertValid();
  122. }
  123.  
  124. void CMainFrame::Dump(CDumpContext& dc) const
  125. {
  126.     CFrameWnd::Dump(dc);
  127. }
  128.  
  129. #endif //_DEBUG
  130.  
  131. /////////////////////////////////////////////////////////////////////////////
  132. // CMainFrame message handlers
  133.