home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / advanced / chatsrvr / mainfrm.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  3KB  |  123 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 "chatsrvr.h"
  15.  
  16. #include "mainfrm.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMainFrame
  25.  
  26. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  29.     //{{AFX_MSG_MAP(CMainFrame)
  30.         // NOTE - the ClassWizard will add and remove mapping macros here.
  31.         //    DO NOT EDIT what you see in these blocks of generated code !
  32.     ON_WM_CREATE()
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // arrays of IDs used to initialize control bars
  38.  
  39. // toolbar buttons - IDs are command buttons
  40. static UINT BASED_CODE buttons[] =
  41. {
  42.     // same order as in the bitmap 'toolbar.bmp'
  43.     ID_FILE_NEW,
  44.     ID_FILE_SAVE,
  45.         ID_SEPARATOR,
  46.     ID_EDIT_CUT,
  47.     ID_EDIT_COPY,
  48.     ID_EDIT_PASTE,
  49.         ID_SEPARATOR,
  50.     ID_APP_ABOUT,
  51. };
  52.  
  53. static UINT BASED_CODE indicators[] =
  54. {
  55.     ID_SEPARATOR,           // status line indicator
  56.     ID_CONNECTIONS,
  57.     ID_MESSAGES,
  58. };
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CMainFrame construction/destruction
  62.  
  63. CMainFrame::CMainFrame()
  64. {
  65. }
  66.  
  67. CMainFrame::~CMainFrame()
  68. {
  69. }
  70.  
  71. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  72. {
  73.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  74.         return -1;
  75.  
  76.     if (!m_wndToolBar.Create(this) ||
  77.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  78.         !m_wndToolBar.SetButtons(buttons,
  79.           sizeof(buttons)/sizeof(UINT)))
  80.     {
  81.         TRACE0("Failed to create toolbar\n");
  82.         return -1;      // fail to create
  83.     }
  84.  
  85.     if (!m_wndStatusBar.Create(this) ||
  86.         !m_wndStatusBar.SetIndicators(indicators,
  87.           sizeof(indicators)/sizeof(UINT)))
  88.     {
  89.         TRACE0("Failed to create status bar\n");
  90.         return -1;      // fail to create
  91.     }
  92.  
  93. #ifdef _WIN32
  94.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  95.     EnableDocking(CBRS_ALIGN_ANY);
  96.     DockControlBar(&m_wndToolBar);
  97.  
  98.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  99.         CBRS_TOOLTIPS | CBRS_FLYBY);
  100. #endif
  101.  
  102.     return 0;
  103. }
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CMainFrame diagnostics
  107.  
  108. #ifdef _DEBUG
  109. void CMainFrame::AssertValid() const
  110. {
  111.     CFrameWnd::AssertValid();
  112. }
  113.  
  114. void CMainFrame::Dump(CDumpContext& dc) const
  115. {
  116.     CFrameWnd::Dump(dc);
  117. }
  118.  
  119. #endif //_DEBUG
  120.  
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CMainFrame message handlers
  123.