MainFrm.cpp
上传用户:donsun
上传日期:2022-08-10
资源大小:36k
文件大小:3k
源码类别:

OpenGL

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "glprint.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_WM_PALETTECHANGED()
  18. ON_WM_QUERYNEWPALETTE()
  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.Create(this) ||
  42. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  43. {
  44. TRACE0("Failed to create toolbarn");
  45. return -1;      // fail to create
  46. }
  47. if (!m_wndStatusBar.Create(this) ||
  48. !m_wndStatusBar.SetIndicators(indicators,
  49.   sizeof(indicators)/sizeof(UINT)))
  50. {
  51. TRACE0("Failed to create status barn");
  52. return -1;      // fail to create
  53. }
  54. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  55. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  56. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  57. // TODO: Delete these three lines if you don't want the toolbar to
  58. //  be dockable
  59. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  60. EnableDocking(CBRS_ALIGN_ANY);
  61. DockControlBar(&m_wndToolBar);
  62. return 0;
  63. }
  64. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  65. {
  66. // TODO: Modify the Window class or styles here by modifying
  67. //  the CREATESTRUCT cs
  68. int cx = ::GetSystemMetrics(SM_CXSCREEN);
  69.     int cy = ::GetSystemMetrics(SM_CYSCREEN);
  70. cs.cx = cx;
  71. cs.cy = cy;
  72. cs.x = 0;
  73. cs.y = 0;
  74. return CFrameWnd::PreCreateWindow(cs);
  75. }
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CMainFrame diagnostics
  78. #ifdef _DEBUG
  79. void CMainFrame::AssertValid() const
  80. {
  81. CFrameWnd::AssertValid();
  82. }
  83. void CMainFrame::Dump(CDumpContext& dc) const
  84. {
  85. CFrameWnd::Dump(dc);
  86. }
  87. #endif //_DEBUG
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CMainFrame message handlers
  90. /********************************************************************/
  91. /* If the window's palette changed                                */
  92. /********************************************************************/
  93. void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) 
  94. {
  95. CFrameWnd::OnPaletteChanged(pFocusWnd);
  96. // TODO: Add your message handler code here
  97. CView* pView = GetActiveView();
  98.     if(pFocusWnd != pView) 
  99. pView->Invalidate(FALSE); 
  100. }
  101. /********************************************************************/
  102. /* If the window's palette changed                                */
  103. /********************************************************************/
  104. BOOL CMainFrame::OnQueryNewPalette() 
  105. {
  106. // TODO: Add your message handler code here and/or call default
  107. CView* pView = GetActiveView();
  108.     pView->Invalidate(FALSE); 
  109. return CFrameWnd::OnQueryNewPalette();
  110. }