MainFrm.cpp
Upload User: fjejplh001
Upload Date: 2007-06-11
Package Size: 324k
Code Size: 5k
Category:

3D Graphic

Development Platform:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "Visual.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMainFrame
  13. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  14. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  15. //{{AFX_MSG_MAP(CMainFrame)
  16. ON_WM_CREATE()
  17. ON_COMMAND(IDM_SHOWTIME, OnShowtime)
  18. ON_WM_TIMER()
  19. ON_COMMAND(IDM_DRAW, OnDraw)
  20. ON_UPDATE_COMMAND_UI(IDM_DRAW, OnUpdateDraw)
  21. ON_COMMAND(IDR_MODIFY, OnModify)
  22. ON_UPDATE_COMMAND_UI(IDR_MODIFY, OnUpdateModify)
  23. //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25. static UINT indicators[] =
  26. {
  27. ID_SEPARATOR,           // status line indicator
  28. ID_SEPARATOR,           
  29. ID_INDICATOR_CAPS,
  30. ID_INDICATOR_NUM,
  31. ID_INDICATOR_SCRL,
  32. };
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CMainFrame construction/destruction
  35. CMainFrame::CMainFrame()
  36. {
  37. // TODO: add member initialization code here
  38. m_bTime=FALSE;
  39. }
  40. CMainFrame::~CMainFrame()
  41. {
  42. }
  43. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  44. {
  45. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  46. return -1;
  47. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  48. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  49. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  50. {
  51. TRACE0("Failed to create toolbarn");
  52. return -1;      // fail to create
  53. }
  54. if (!m_wndStatusBar.Create(this) ||
  55. !m_wndStatusBar.SetIndicators(indicators,
  56.   sizeof(indicators)/sizeof(UINT)))
  57. {
  58. TRACE0("Failed to create status barn");
  59. return -1;      // fail to create
  60. }
  61. if (!m_wndModify.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_LEFT
  62. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  63. !m_wndModify.LoadToolBar(IDR_MODIFY))
  64. {
  65. TRACE0("Failed to create toolbarn");
  66. return -1;      // fail to create
  67. }
  68. if (!m_wndDraw.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_RIGHT
  69. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  70. !m_wndDraw.LoadToolBar(IDR_DRAW))
  71. {
  72. TRACE0("Failed to create toolbarn");
  73. return -1;      // fail to create
  74. }
  75. // TODO: Delete these three lines if you don't want the toolbar to
  76. //  be dockable
  77. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  78. EnableDocking(CBRS_ALIGN_ANY);
  79. DockControlBar(&m_wndToolBar);
  80. m_wndModify.EnableDocking(CBRS_ALIGN_ANY);
  81. EnableDocking(CBRS_ALIGN_ANY);
  82. DockControlBar(&m_wndModify);
  83. m_wndDraw.EnableDocking(CBRS_ALIGN_ANY);
  84. EnableDocking(CBRS_ALIGN_ANY);
  85. DockControlBar(&m_wndDraw);
  86. m_wndStatusBar.SetPaneInfo(1,ID_SEPARATOR,SBPS_NORMAL,47);
  87. return 0;
  88. LoadBarState("MyToolBarSettings");
  89. }
  90. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  91. {
  92. // TODO: Modify the Window class or styles here by modifying
  93. //  the CREATESTRUCT cs
  94. cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
  95. | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;
  96. return CMDIFrameWnd::PreCreateWindow(cs);
  97. }
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CMainFrame diagnostics
  100. #ifdef _DEBUG
  101. void CMainFrame::AssertValid() const
  102. {
  103. CMDIFrameWnd::AssertValid();
  104. }
  105. void CMainFrame::Dump(CDumpContext& dc) const
  106. {
  107. CMDIFrameWnd::Dump(dc);
  108. }
  109. #endif //_DEBUG
  110. /////////////////////////////////////////////////////////////////////////////
  111. // CMainFrame message handlers
  112. void CMainFrame::OnShowtime() 
  113. {
  114. // TODO: Add your command handler code here
  115. m_bTime = m_bTime ? FALSE : TRUE;
  116. if (m_bTime)
  117. m_timer=SetTimer(1,1000,NULL);
  118. else
  119. { KillTimer(m_timer);
  120. m_wndStatusBar.SetPaneText(1,"");
  121. }
  122. }
  123. void CMainFrame::OnTimer(UINT nIDEvent) 
  124. {
  125. // TODO: Add your message handler code here and/or call default
  126. char str[32];
  127. struct tm *osTime;
  128. CTime t=CTime::GetCurrentTime();
  129. osTime=t.GetLocalTm(NULL);
  130. sprintf(str,"%02d:%02d:%02d",
  131. osTime->tm_hour,osTime->tm_min,osTime->tm_sec);
  132. m_wndStatusBar.SetPaneText(1,str);
  133. CMDIFrameWnd::OnTimer(nIDEvent);
  134. }
  135. void CMainFrame::OnDraw() 
  136. {
  137. // TODO: Add your command handler code here
  138. m_bDraw=!m_bDraw;
  139. ShowControlBar(&m_wndDraw,m_bDraw,FALSE);
  140. }
  141. void CMainFrame::OnUpdateDraw(CCmdUI* pCmdUI) 
  142. {
  143. // TODO: Add your command update UI handler code here
  144. pCmdUI->Enable();
  145. pCmdUI->SetCheck(m_bDraw);
  146. }
  147. void CMainFrame::OnModify() 
  148. {
  149. // TODO: Add your command handler code here
  150. m_bModify=!m_bModify;
  151. ShowControlBar(&m_wndModify,m_bModify,FALSE);
  152. }
  153. void CMainFrame::OnUpdateModify(CCmdUI* pCmdUI) 
  154. {
  155. // TODO: Add your command update UI handler code here
  156. pCmdUI->Enable();
  157. pCmdUI->SetCheck(m_bModify);
  158. }