MAINFRM.CPP
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:3k
源码类别:

VC书籍

开发平台:

Visual C++

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. #include "stdafx.h"
  13. #include "RevPlayMDIChildWnd.h"
  14. #include "mdi.h"
  15. #include "mainfrm.h"
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char BASED_CODE THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CMainFrame
  22. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  23. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  24. //{{AFX_MSG_MAP(CMainFrame)
  25. ON_COMMAND(IDM_REQUEST, OnRequest)
  26. ON_WM_CREATE()
  27. //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CMainFrame construction/destruction
  31. static UINT indicators[] =
  32. {
  33. ID_SEPARATOR,           // status line indicator
  34. ID_SEPARATOR,
  35. ID_SEPARATOR,
  36. ID_SEPARATOR,
  37. };
  38. CMainFrame::CMainFrame()
  39. {
  40. }
  41. CMainFrame::~CMainFrame()
  42. {
  43. }
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CMainFrame commands
  46. static BOOL CALLBACK SendPrepareToClose(HWND hWnd, LPARAM)
  47. {
  48. CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);
  49. if (pWnd != NULL)
  50. {
  51. pWnd->SendMessage(WM_USER_PREPARE_TO_CLOSE);
  52. if (pWnd->GetWindow(GW_CHILD) != NULL)
  53. ::EnumChildWindows(pWnd->m_hWnd, SendPrepareToClose, 0);
  54. }
  55. return TRUE;
  56. }
  57. BOOL CMainFrame::DestroyWindow()
  58. {
  59. ::EnumChildWindows(m_hWnd, SendPrepareToClose, 0);
  60. return CMDIFrameWnd::DestroyWindow();
  61. }
  62. void CMainFrame::OnRequest() 
  63. {
  64. // TODO: Add your command handler code here
  65. RECT rect;
  66. CRevPlayMDIChildWnd *pRevPlayMDIChildWnd = new CRevPlayMDIChildWnd;
  67. GetClientRect(&rect);
  68. //调用子框架窗口的创建函数
  69. if (!pRevPlayMDIChildWnd->Create( _T("接收播放"),rect,this))
  70. return;
  71. }
  72. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  73. {
  74. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  75. return -1;
  76. // TODO: Add your specialized creation code here
  77. if (!m_wndStatusBar.Create(this,WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,ID_STATUS_BAR)
  78. ||!m_wndStatusBar.SetIndicators(indicators,
  79.   sizeof(indicators)/sizeof(UINT)))
  80. {
  81. TRACE0("Failed to create status barn");
  82. return -1;      // fail to create
  83. }
  84.    return 0;
  85. }