Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
2.9 KiB

  1. // ChildFrm.cpp : implementation of the CChildFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "mditest.h"
  5. #include "ChildFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CChildFrame
  13. IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
  14. BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
  15. //{{AFX_MSG_MAP(CChildFrame)
  16. ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
  17. ON_WM_SETFOCUS()
  18. ON_WM_CREATE()
  19. ON_COMMAND(ID_FULLMDIMAXIMIZED, OnFullMdiMaximized)
  20. ON_UPDATE_COMMAND_UI(ID_FULLMDIMAXIMIZED, OnUpdateFullMdiMaximized)
  21. ON_WM_GETMINMAXINFO()
  22. //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CChildFrame construction/destruction
  26. CChildFrame::CChildFrame()
  27. : m_fFullMdiMax(TRUE)
  28. {
  29. }
  30. CChildFrame::~CChildFrame()
  31. {
  32. }
  33. BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
  34. {
  35. if( !CMDIChildWnd::PreCreateWindow(cs) )
  36. return FALSE;
  37. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  38. cs.lpszClass = AfxRegisterWndClass(0);
  39. return TRUE;
  40. }
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CChildFrame diagnostics
  43. #ifdef _DEBUG
  44. void CChildFrame::AssertValid() const
  45. {
  46. CMDIChildWnd::AssertValid();
  47. }
  48. void CChildFrame::Dump(CDumpContext& dc) const
  49. {
  50. CMDIChildWnd::Dump(dc);
  51. }
  52. #endif //_DEBUG
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CChildFrame message handlers
  55. void CChildFrame::OnFileClose()
  56. {
  57. SendMessage(WM_CLOSE);
  58. }
  59. int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  60. {
  61. if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
  62. return -1;
  63. // create a view to occupy the client area of the frame
  64. if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
  65. CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
  66. {
  67. TRACE0("Failed to create view window\n");
  68. return -1;
  69. }
  70. return 0;
  71. }
  72. void CChildFrame::OnSetFocus(CWnd* pOldWnd)
  73. {
  74. CMDIChildWnd::OnSetFocus(pOldWnd);
  75. m_wndView.SetFocus();
  76. }
  77. BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  78. {
  79. // let the view have first crack at the command
  80. if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  81. return TRUE;
  82. // otherwise, do default handling
  83. return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  84. }
  85. void CChildFrame::OnFullMdiMaximized()
  86. {
  87. m_fFullMdiMax = !m_fFullMdiMax;
  88. }
  89. void CChildFrame::OnUpdateFullMdiMaximized(CCmdUI* pCmdUI)
  90. {
  91. pCmdUI->SetCheck( m_fFullMdiMax );
  92. }
  93. void CChildFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
  94. {
  95. CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
  96. if( !m_fFullMdiMax )
  97. {
  98. CWnd* pParent = GetParent();
  99. if( pParent )
  100. {
  101. RECT rc;
  102. pParent->GetClientRect( &rc );
  103. lpMMI->ptMaxTrackSize.x = (rc.right - rc.left)/2;
  104. lpMMI->ptMaxTrackSize.y = (rc.bottom - rc.top)/2;
  105. }
  106. }
  107. }