home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / beaversweeper_v101.zip / src / MainFrm.cpp < prev    next >
C/C++ Source or Header  |  2005-10-07  |  5KB  |  176 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tracker.h"
  6. #include "sampleView.h"
  7. #include "trackerview.h"
  8.  
  9. #include "MainFrm.h"
  10. #include "TrackerControls.h"
  11. #include "trackerscopes.h"
  12.  
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CMainFrame
  21.  
  22. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  23.  
  24. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  25.     ON_MESSAGE(WM_USER+10,OnPaneText)
  26.     //{{AFX_MSG_MAP(CMainFrame)
  27.     ON_WM_CREATE()
  28.     ON_WM_KEYDOWN()
  29.     ON_WM_SIZE()
  30.     //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32.  
  33. static UINT indicators[] =
  34. {
  35.     ID_SEPARATOR,           // status line indicator
  36.         ID_INDICATOR_CAPS,
  37.         ID_INDICATOR_NUM,
  38.         ID_INDICATOR_SCRL,
  39. };
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CMainFrame construction/destruction
  43.  
  44. CMainFrame::CMainFrame()
  45. {
  46.     // TODO: add member initialization code here
  47.  
  48. }
  49.  
  50. CMainFrame::~CMainFrame()
  51. {    
  52. }
  53.  
  54. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  55. {
  56.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  57.         return -1;
  58.  
  59.     if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  60.         | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  61.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  62.     {
  63.         TRACE0("Failed to create toolbar\n");
  64.         return -1;      // fail to create
  65.     }
  66.  
  67.     if (!m_wndStatusBar.Create(this) ||
  68.         !m_wndStatusBar.SetIndicators(indicators,
  69.         sizeof(indicators)/sizeof(UINT)))
  70.     {
  71.         TRACE0("Failed to create status bar\n");
  72.         return -1;      // fail to create
  73.     }
  74.  
  75.     if (!m_trackerControls.Create (this,IDD_DIALOG_TRACKER_CNTRL,CBRS_GRIPPER|CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY, IDD_DIALOG_TRACKER_CNTRL))
  76.     {
  77.         TRACE0("Failed to create tracker controls\n");
  78.         return -1;
  79.     }
  80.     if (!m_trackerScopes.Create (this,IDD_DIALOG_SCOPES,CBRS_GRIPPER|CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY, IDD_DIALOG_TRACKER_CNTRL))
  81.     {
  82.         TRACE0("Failed to create tracker controls\n");
  83.         return -1;
  84.     }
  85.     // TODO: Delete these three lines if you don't want the toolbar to
  86.     //  be dockable
  87.     m_trackerControls.SetCaption("TrackerControls");
  88.     m_trackerScopes.SetCaption("TrackerScopes");
  89.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  90.     m_trackerControls.EnableDocking(CBRS_ALIGN_ANY);
  91.     m_trackerScopes.EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM);
  92.     EnableDocking(CBRS_ALIGN_ANY);
  93.     DockControlBar(&m_wndToolBar);
  94.     DockControlBar(&m_trackerControls);
  95.     DockControlBar(&m_trackerScopes,AFX_IDW_DOCKBAR_BOTTOM);
  96.  
  97.     return 0;
  98. }
  99.  
  100. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  101. {
  102.     if( !CMDIFrameWnd::PreCreateWindow(cs) )
  103.         return FALSE;
  104.     // TODO: Modify the Window class or styles here by modifying
  105.     //  the CREATESTRUCT cs
  106.  
  107.     return TRUE;
  108. }
  109.  
  110. /////////////////////////////////////////////////////////////////////////////
  111. // CMainFrame diagnostics
  112.  
  113. #ifdef _DEBUG
  114. void CMainFrame::AssertValid() const
  115. {
  116.     CMDIFrameWnd::AssertValid();
  117. }
  118.  
  119. void CMainFrame::Dump(CDumpContext& dc) const
  120. {
  121.     CMDIFrameWnd::Dump(dc);
  122. }
  123.  
  124. #endif //_DEBUG
  125.  
  126. /////////////////////////////////////////////////////////////////////////////
  127. // CMainFrame message handlers
  128.  
  129. /*
  130. void CMainFrame::OnMenuSampleview() 
  131. {
  132. // TODO: Add your command handler code here
  133. CMDIChildWnd* pOutFrame;
  134. CMSDIWinApp* pApp = (CMSDIWinApp*)AfxGetApp();
  135.  
  136. pOutFrame = pApp->CreateOrActivateFrame(RUNTIME_CLASS(CInstrEditor), NULL);
  137. m_pInstrEditor = (CInstrEditor*)pOutFrame->GetActiveView();
  138. ASSERT(m_pInstrEditor != NULL);
  139. ASSERT(m_pInstrEditor->IsKindOf(RUNTIME_CLASS(CInstrEditor)));
  140.  
  141. }
  142. */
  143.  
  144. void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  145. {
  146.     // TODO: Add your message handler code here and/or call default
  147.     CView *mvPtr,*mvPtr2;
  148.  
  149.     mvPtr = GetActiveView ();
  150.     if (mvPtr != NULL)
  151.     {
  152.         mvPtr2 = (CView *)RUNTIME_CLASS (CPatternView);
  153.     }
  154.  
  155.     CMDIFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
  156. }
  157. LRESULT CMainFrame::OnPaneText (WPARAM p, LPARAM l)
  158. {
  159.     char buffer[128];
  160.  
  161.     m_trackerControls.m_cpuUsage=100*atoi((char *)l);
  162.     m_trackerControls.UpdateData(FALSE);
  163.     sprintf (buffer,"%s",(char *)l);
  164.     m_wndStatusBar.SetPaneText (0,buffer,TRUE);
  165.  
  166.     return 0;
  167. }
  168.  
  169. void CMainFrame::OnSize(UINT nType, int cx, int cy) 
  170. {
  171.     CMDIFrameWnd::OnSize(nType, cx, cy);
  172.     m_trackerControls.SendMessage(WM_SIZE,nType,((cy&0xffff)<<16) | (cx & 0xffff));
  173.     // TODO: Add your message handler code here
  174.  
  175. }
  176.