MainFrm.cpp
上传用户:xp9161
上传日期:2009-12-21
资源大小:70k
文件大小:2k
源码类别:

Windows编程

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "QZoomViewDemo.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #endif
  9. const int TimerID = 3;
  10. const int TimerPeriod = 4000;
  11. const int FirstMessage = 1000;
  12. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  13. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  14. ON_WM_CREATE()
  15. ON_WM_TIMER()
  16. ON_WM_DESTROY()
  17. END_MESSAGE_MAP()
  18. static UINT indicators[] =
  19. {
  20. ID_SEPARATOR,           // status line indicator
  21. //++++++++++++++++++++++++++++++++++
  22. // One indicator ID added.
  23. // It is handled in class QZVDemoView.
  24. ID_INDICATOR_ZOOM,
  25. //
  26. //
  27. //+++++++++++++++++++++++++++++++++
  28. ID_INDICATOR_CAPS,
  29. ID_INDICATOR_NUM,
  30. ID_INDICATOR_SCRL,
  31. };
  32. CMainFrame::CMainFrame()
  33. : m_iMessage(FirstMessage)
  34. {
  35. }
  36. CMainFrame::~CMainFrame()
  37. {
  38. }
  39. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  40. {
  41. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  42. return -1;
  43. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  44. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  45. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  46. {
  47. TRACE0("Failed to create toolbarn");
  48. return -1;
  49. }
  50. if (!m_wndStatusBar.Create(this) ||
  51. !m_wndStatusBar.SetIndicators(indicators,
  52.   sizeof(indicators)/sizeof(UINT)))
  53. {
  54. TRACE0("Failed to create status barn");
  55. return -1;
  56. }
  57. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  58. EnableDocking(CBRS_ALIGN_ANY);
  59. DockControlBar(&m_wndToolBar);
  60. SetTimer(TimerID, TimerPeriod, NULL);
  61. return 0;
  62. }
  63. void CMainFrame::OnTimer(UINT nIDEvent)
  64. {
  65. if (nIDEvent == TimerID)
  66. {
  67. CString s;
  68. if (! s.LoadString(m_iMessage++))
  69. {
  70. m_iMessage = FirstMessage;
  71. s.LoadString(m_iMessage++);
  72. }
  73. SetMessageText(s);
  74. }
  75. CFrameWnd::OnTimer(nIDEvent);
  76. }
  77. void CMainFrame::OnDestroy()
  78. {
  79. CFrameWnd::OnDestroy();
  80. KillTimer(TimerPeriod);
  81. }