home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / beaversweeper_v101.zip / src / VIEWFRM.CPP < prev    next >
C/C++ Source or Header  |  2003-01-06  |  2KB  |  94 lines

  1. // viewfrm.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char BASED_CODE THIS_FILE[] = __FILE__;
  9. #endif
  10.  
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CViewFrame
  13.  
  14. IMPLEMENT_DYNCREATE(CViewFrame, CMDIChildWnd)
  15.  
  16. CViewFrame::CViewFrame()
  17. {
  18. }
  19.  
  20. CViewFrame::~CViewFrame()
  21. {
  22. }
  23.  
  24. BEGIN_MESSAGE_MAP(CViewFrame, CMDIChildWnd)
  25.   //{{AFX_MSG_MAP(CViewFrame)
  26.   ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
  27.   ON_WM_CREATE()
  28.   //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30.  
  31. BOOL CViewFrame::PreCreateWindow(CREATESTRUCT& cs)
  32. {
  33.   // By turning off the default MFC-defined FWS_ADDTOTITLE style,
  34.   // the framework will use first string in the document template
  35.   // STRINGTABLE resource instead of the document name.
  36.   cs.style &= ~(LONG)FWS_ADDTOTITLE;
  37.   return CMDIChildWnd::PreCreateWindow(cs);
  38. }
  39.  
  40. int CViewFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  41. {
  42.   if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
  43.     return -1;
  44.  
  45.   // if not exist, get shared menu & accelerator table from first doc template
  46.   if (!m_hMenuShared || !m_hAccelTable)
  47.   {
  48.     CMSDIWinApp* pApp = (CMSDIWinApp*)AfxGetApp();
  49.     POSITION pos = pApp->GetFirstDocTemplatePosition();
  50.     CMSDITemplate* pTemplate =
  51.       (CMSDITemplate*)pApp->GetNextDocTemplate(pos);
  52.     if (pTemplate)
  53.     {
  54.       if (!m_hMenuShared)
  55.   m_hMenuShared = pTemplate->m_hMenuShared;
  56.       if (!m_hAccelTable)
  57.   m_hAccelTable = pTemplate->m_hAccelTable;
  58.     }
  59.   }
  60.   return 0;
  61. }
  62.  
  63. void CViewFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
  64. {
  65.   if (bAddToTitle)
  66.   {
  67.     char szBuffer[256];
  68.     char szOldTitle[256];
  69.     GetWindowText(szOldTitle, sizeof(szOldTitle));
  70.  
  71.     CString strTitle;
  72.     CMSDIWinApp* pApp = (CMSDIWinApp*)AfxGetApp();
  73.     ASSERT(pApp != NULL);
  74.     CMSDITemplate* pTemplate = pApp->GetDocTemplate(GetActiveView());
  75.     ASSERT(pTemplate != NULL);
  76.     pTemplate->GetDocString(strTitle, CDocTemplate::windowTitle);
  77.     strcpy(szBuffer, strTitle);
  78.  
  79.     // set title if changed, but don't remove completely
  80.     if (lstrcmp(szBuffer, szOldTitle) != 0)
  81.       SetWindowText(szBuffer);
  82.   }
  83. }
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. // CViewFrame functions
  87.  
  88. LRESULT CViewFrame::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)
  89. {
  90.   CMDIChildWnd::OnIdleUpdateCmdUI();    // pass to default handler
  91.   OnUpdateFrameTitle(TRUE);
  92.   return 0L;
  93. }
  94.