MainFrm.cpp
上传用户:do_tie
上传日期:2007-11-03
资源大小:1095k
文件大小:3k
源码类别:

GDI/图象编程

开发平台:

Visual C++

  1. // MainFrm.cpp : CMainFrame 类的实现
  2. //
  3. #include "stdafx.h"
  4. #include "GandyDraw.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #endif
  9. // CMainFrame
  10. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  11. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  12. ON_WM_CREATE()
  13. END_MESSAGE_MAP()
  14. static UINT indicators[] =
  15. {
  16. ID_SEPARATOR,   // 状态行指示器
  17. ID_SEPARATOR,
  18. ID_SEPARATOR,
  19. ID_SEPARATOR,
  20. ID_SEPARATOR,
  21. ID_SEPARATOR,
  22. ID_SEPARATOR,
  23. ID_SEPARATOR,
  24. ID_SEPARATOR,
  25. };
  26. // CMainFrame 构造/析构
  27. CMainFrame::CMainFrame()
  28. {
  29. // TODO: 在此添加成员初始化代码
  30. }
  31. CMainFrame::~CMainFrame()
  32. {
  33. }
  34. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  35. {
  36. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  37. return -1;
  38. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  39. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  40. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  41. {
  42. TRACE0("未能创建工具栏n");
  43. return -1;      // 未能创建
  44. }
  45. // TODO 绘图风格工具栏的创建
  46. if (!m_ToolBar_ds.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | 
  47. CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | 
  48. CBRS_SIZE_DYNAMIC) || !m_ToolBar_ds.LoadToolBar(IDR_DRAWSTYLE))
  49. {
  50. TRACE0("未能创建工具栏n");
  51. return -1;      // 未能创建
  52. }
  53. if (!m_wndStatusBar.Create(this) ||
  54. !m_wndStatusBar.SetIndicators(indicators,
  55.   sizeof(indicators)/sizeof(UINT)))
  56. {
  57. TRACE0("未能创建状态栏n");
  58. return -1;      // 未能创建
  59. }
  60. // TODO: 如果不需要工具栏可停靠,则删除这三行
  61. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  62. EnableDocking(CBRS_ALIGN_ANY);
  63. DockControlBar(&m_wndToolBar);
  64. m_ToolBar_ds.EnableDocking(CBRS_ALIGN_ANY);
  65. EnableDocking(CBRS_ALIGN_ANY);
  66. DockControlBar(&m_ToolBar_ds);
  67. m_wndStatusBar.SetPaneInfo(0, prompt, SBPS_STRETCH,0); // 提示
  68. m_wndStatusBar.SetPaneInfo(1, xName, SBPS_NOBORDERS, 8); // "x:"
  69. m_wndStatusBar.SetPaneText(xName, L"x:");
  70. m_wndStatusBar.SetPaneInfo(2, xVal, SBPS_NORMAL, 24); // x值
  71. m_wndStatusBar.SetPaneInfo(3, yName, SBPS_NOBORDERS, 8); // "y:"
  72. m_wndStatusBar.SetPaneText(yName, L"y:");
  73. m_wndStatusBar.SetPaneInfo(4, yVal, SBPS_NORMAL, 24); // y值
  74. m_wndStatusBar.SetPaneInfo(5, dxName, SBPS_NOBORDERS, 8); // "dx:"
  75. m_wndStatusBar.SetPaneText(dxName, L"dx:");
  76. m_wndStatusBar.SetPaneInfo(6, dxVal, SBPS_NORMAL, 24); // dx值
  77. m_wndStatusBar.SetPaneInfo(7, dyName, SBPS_NOBORDERS, 8); // "dy:"
  78. m_wndStatusBar.SetPaneText(dyName, L"dy:");
  79. m_wndStatusBar.SetPaneInfo(8, dyVal, SBPS_NORMAL, 24); // dy值
  80. return 0;
  81. }
  82. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  83. {
  84. if( !CFrameWnd::PreCreateWindow(cs) )
  85. return FALSE;
  86. // TODO: 在此处通过修改
  87. //  CREATESTRUCT cs 来修改窗口类或样式
  88. return TRUE;
  89. }
  90. // CMainFrame 诊断
  91. #ifdef _DEBUG
  92. void CMainFrame::AssertValid() const
  93. {
  94. CFrameWnd::AssertValid();
  95. }
  96. void CMainFrame::Dump(CDumpContext& dc) const
  97. {
  98. CFrameWnd::Dump(dc);
  99. }
  100. #endif //_DEBUG
  101. // CMainFrame 消息处理程序