MainFrm.cpp
上传用户:nhyuejuan
上传日期:2013-12-02
资源大小:171k
文件大小:3k
源码类别:

状态条

开发平台:

Visual C++

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Project:PGRSBAR
  3. // Author:NorthTibet
  4. // Date:星期二, 十二月 31, 2002
  5. // Description:在状态栏例实现进程指示器控制。
  6. //
  7. /////////////////////////////////////////////////////////////////////////////
  8. // MainFrm.cpp : implementation of the CMainFrame class
  9. //
  10. #include "stdafx.h"
  11. #include "pgrsbar.h"
  12. #include "MainFrm.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMainFrame
  20. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  21. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  22. //{{AFX_MSG_MAP(CMainFrame)
  23. // NOTE - the ClassWizard will add and remove mapping macros here.
  24. //    DO NOT EDIT what you see in these blocks of generated code !
  25. ON_WM_CREATE()
  26. //}}AFX_MSG_MAP
  27. ON_MESSAGE(MYWM_PROGRESS,OnProgress)
  28. END_MESSAGE_MAP()
  29. static UINT indicators[] =
  30. {
  31. ID_SEPARATOR,           // status line indicator
  32. ID_INDICATOR_CAPS,
  33. ID_INDICATOR_NUM,
  34. ID_INDICATOR_SCRL,
  35. };
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CMainFrame construction/destruction
  38. CMainFrame::CMainFrame()
  39. {
  40. // TODO: add member initialization code here
  41. }
  42. CMainFrame::~CMainFrame()
  43. {
  44. }
  45. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  46. {
  47. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  48. return -1;
  49. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  50. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  51. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  52. {
  53. TRACE0("Failed to create toolbarn");
  54. return -1;      // fail to create
  55. }
  56. if (!m_wndStatusBar.Create(this) ||
  57. !m_wndStatusBar.SetIndicators(indicators,
  58.   sizeof(indicators)/sizeof(UINT)))
  59. {
  60. TRACE0("Failed to create status barn");
  61. return -1;      // fail to create
  62. }
  63. // TODO: Delete these three lines if you don't want the toolbar to
  64. //  be dockable
  65. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  66. EnableDocking(CBRS_ALIGN_ANY);
  67. DockControlBar(&m_wndToolBar);
  68. return 0;
  69. }
  70. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  71. {
  72. if( !CFrameWnd::PreCreateWindow(cs) )
  73. return FALSE;
  74. // TODO: Modify the Window class or styles here by modifying
  75. //  the CREATESTRUCT cs
  76. return TRUE;
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CMainFrame diagnostics
  80. #ifdef _DEBUG
  81. void CMainFrame::AssertValid() const
  82. {
  83. CFrameWnd::AssertValid();
  84. }
  85. void CMainFrame::Dump(CDumpContext& dc) const
  86. {
  87. CFrameWnd::Dump(dc);
  88. }
  89. #endif //_DEBUG
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CMainFrame message handlers
  92. ///////////////////
  93. // Handle progress message--any object can call send one.
  94. //
  95. LRESULT CMainFrame::OnProgress(WPARAM wp, LPARAM lp)
  96. {
  97. m_wndStatusBar.OnProgress(wp); // pass to prog/status bar
  98. return 0;
  99. }