MainFrm.cpp
Upload User: herolh
Upload Date: 2022-07-18
Package Size: 3590k
Code Size: 3k
Category:

Graph Drawing

Development Platform:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "Graphic.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_DYNCREATE(CMainFrame, CFrameWnd)
  14. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  15. //{{AFX_MSG_MAP(CMainFrame)
  16. ON_WM_CREATE()
  17. ON_COMMAND(ID_DRAWTOOLBAR, OnDrawtoolbar)
  18. ON_UPDATE_COMMAND_UI(ID_DRAWTOOLBAR, OnUpdateDrawtoolbar)
  19. //}}AFX_MSG_MAP
  20. END_MESSAGE_MAP()
  21. static UINT indicators[] =
  22. {
  23. ID_SEPARATOR,           // status line indicator
  24. ID_INDICATOR_CAPS,
  25. ID_INDICATOR_NUM,
  26. ID_INDICATOR_SCRL,
  27. };
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CMainFrame construction/destruction
  30. CMainFrame::CMainFrame()
  31. {
  32. // TODO: add member initialization code here
  33. }
  34. CMainFrame::~CMainFrame()
  35. {
  36. }
  37. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  38. {
  39. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  40. return -1;
  41. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  42. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  43. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  44. {
  45. TRACE0("Failed to create toolbarn");
  46. return -1;      // fail to create
  47. }
  48. if (!m_wndStatusBar.Create(this) ||
  49. !m_wndStatusBar.SetIndicators(indicators,
  50.   sizeof(indicators)/sizeof(UINT)))
  51. {
  52. TRACE0("Failed to create status barn");
  53. return -1;      // fail to create
  54. }
  55. // TODO: Delete these three lines if you don't want the toolbar to
  56. //  be dockable
  57. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  58. EnableDocking(CBRS_ALIGN_ANY);
  59. DockControlBar(&m_wndToolBar);
  60. if (!m_newToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_RIGHT
  61. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  62. !m_newToolBar.LoadToolBar(IDR_TOOLBAR1))
  63. {
  64. TRACE0("Failed to create toolbarn");
  65. return -1;      // fail to create
  66. }
  67. m_newToolBar.EnableDocking(CBRS_ALIGN_ANY);
  68. DockControlBar(&m_newToolBar);
  69. return 0;
  70. }
  71. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  72. {
  73. if( !CFrameWnd::PreCreateWindow(cs) )
  74. return FALSE;
  75. // TODO: Modify the Window class or styles here by modifying
  76. //  the CREATESTRUCT cs
  77. cs.style=WS_OVERLAPPEDWINDOW;
  78. cs.lpszName="画图";
  79. return TRUE;
  80. }
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CMainFrame diagnostics
  83. #ifdef _DEBUG
  84. void CMainFrame::AssertValid() const
  85. {
  86. CFrameWnd::AssertValid();
  87. }
  88. void CMainFrame::Dump(CDumpContext& dc) const
  89. {
  90. CFrameWnd::Dump(dc);
  91. }
  92. #endif //_DEBUG
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CMainFrame message handlers
  95. void CMainFrame::OnDrawtoolbar() 
  96. {
  97. // TODO: Add your command handler code here
  98. if(m_newToolBar.IsWindowVisible())
  99. m_newToolBar.ShowWindow(SW_HIDE);
  100. else
  101. m_newToolBar.ShowWindow(SW_SHOW);
  102. RecalcLayout();
  103. //CRect rct;
  104. //m_newToolBar.GetItemRect(m_newToolBar.CommandToIndex(IDR_TOOLBAR1),rct);
  105. //DockControlBar(&m_newToolBar);
  106. }
  107. void CMainFrame::OnUpdateDrawtoolbar(CCmdUI* pCmdUI) 
  108. {
  109. pCmdUI->SetCheck(m_newToolBar.IsWindowVisible());
  110. }