home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / internet / stockticker / containermfc / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.9 KB  |  119 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.  
  14. #include "stdafx.h"
  15. #include "containerMFC.h"
  16. #include "containerMFCDoc.h"
  17. #include "MainFrm.h"
  18.  
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CMainFrame
  27.  
  28. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  29.  
  30. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  31.     //{{AFX_MSG_MAP(CMainFrame)
  32.     ON_WM_INITMENUPOPUP()
  33.     //}}AFX_MSG_MAP
  34.     ON_WM_SYSCOMMAND()
  35. END_MESSAGE_MAP()
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CMainFrame construction/destruction
  39.  
  40. CMainFrame::CMainFrame()
  41. {
  42.     // TODO: add member initialization code here
  43.  
  44. }
  45.  
  46. CMainFrame::~CMainFrame()
  47. {
  48. }
  49.  
  50. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  51. {
  52.     cs.cy = 60;
  53.     cs.cx = 300;
  54.     cs.hMenu = 0;       // don't want a menu.
  55.     return CFrameWnd::PreCreateWindow(cs);
  56. }
  57.  
  58. void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
  59. {
  60.     // don't call base class version so "Untitled -" is not prepended.
  61. }
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CMainFrame diagnostics
  65.  
  66. #ifdef _DEBUG
  67. void CMainFrame::AssertValid() const
  68. {
  69.     CFrameWnd::AssertValid();
  70. }
  71.  
  72. void CMainFrame::Dump(CDumpContext& dc) const
  73. {
  74.     CFrameWnd::Dump(dc);
  75. }
  76.  
  77. #endif //_DEBUG
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CMainFrame message handlers
  81.  
  82. void CMainFrame::Serialize(CArchive& ar)
  83. {
  84.     if (ar.IsStoring())
  85.     {   // storing code
  86.     }
  87.     else
  88.     {   // loading code
  89.     }
  90. }
  91.  
  92. void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
  93. {
  94.     if ((nID & 0xFFF0) == ID_APP_ABOUT)     // pass onto app.
  95.         ((CContainerMFCApp*)AfxGetApp())->OnAppAbout();
  96.     else if ((nID & 0xFFF0) == ID_STAY_ON_TOP)
  97.     {
  98.         CMenu* pSysMenu = AfxGetMainWnd()->GetSystemMenu(FALSE);
  99.         ASSERT(pSysMenu);
  100.         if (pSysMenu)
  101.         {
  102.             bool    bChecked = pSysMenu->GetMenuState(ID_STAY_ON_TOP, MF_BYCOMMAND) == MF_CHECKED;
  103.             ((CContainerMFCDoc*)GetActiveDocument())->SetStayOnTop(this, !bChecked);
  104.         }
  105.     }
  106.     else
  107.         CFrameWnd::OnSysCommand(nID, lParam);
  108. }
  109.  
  110.  
  111. void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
  112. {
  113.     CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
  114.  
  115.     bool    bChecked = pPopupMenu->GetMenuState(ID_STAY_ON_TOP, MF_BYCOMMAND) == MF_CHECKED;
  116.     pPopupMenu->CheckMenuItem(ID_STAY_ON_TOP,
  117.         MF_BYCOMMAND | (bChecked ? MF_UNCHECKED : MF_CHECKED));
  118. }
  119.