MainFrm.cpp
上传用户:jyxwjx
上传日期:2020-03-13
资源大小:221k
文件大小:3k
源码类别:

多显示器编程

开发平台:

Visual C++

  1. // MainFrm.cpp : CMainFrame 努贰胶狼 备泅
  2. //
  3. #include "stdafx.h"
  4. #include "MM.h"
  5. #include "MainFrm.h"
  6. #include "Dialog1.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #endif
  10. // CMainFrame
  11. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  12. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  13. ON_WM_CREATE()
  14. ON_WM_DESTROY()
  15. ON_COMMAND(ID_VIEW_DIALOG, OnViewDialog)
  16. END_MESSAGE_MAP()
  17. static UINT indicators[] =
  18. {
  19. ID_SEPARATOR,           // 惑怕 临 钎矫扁
  20. ID_INDICATOR_CAPS,
  21. ID_INDICATOR_NUM,
  22. ID_INDICATOR_SCRL,
  23. };
  24. // CMainFrame 积己/家戈
  25. CMainFrame::CMainFrame()
  26. {
  27. // TODO: 咯扁俊 糕滚 檬扁拳 内靛甫 眠啊钦聪促.
  28. }
  29. CMainFrame::~CMainFrame()
  30. {
  31. int nCount = m_aryDlg.GetCount();
  32. for(int i=0;i<nCount;i++)
  33. {
  34. CDialog1* pDlg = (CDialog1*)m_aryDlg.GetAt(i);
  35. if(pDlg)
  36. delete pDlg;
  37. }
  38. m_aryDlg.RemoveAll();
  39. m_aryDlg.FreeExtra();
  40. }
  41. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  42. {
  43. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  44. return -1;
  45. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  46. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  47. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  48. {
  49. TRACE0("档备 葛澜阑 父甸瘤 给沁嚼聪促.n");
  50. return -1;      // 父甸瘤 给沁嚼聪促.
  51. }
  52. if (!m_wndStatusBar.Create(this) ||
  53. !m_wndStatusBar.SetIndicators(indicators,
  54.   sizeof(indicators)/sizeof(UINT)))
  55. {
  56. TRACE0("惑怕 钎矫临阑 父甸瘤 给沁嚼聪促.n");
  57. return -1;      // 父甸瘤 给沁嚼聪促.
  58. }
  59. // TODO: 档备 葛澜阑 档欧且 荐 绝霸 窍妨搁 捞 技 临阑 昏力窍绞矫坷.
  60. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  61. EnableDocking(CBRS_ALIGN_ANY);
  62. DockControlBar(&m_wndToolBar);
  63. return 0;
  64. }
  65. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  66. {
  67. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  68. return FALSE;
  69. // TODO: CREATESTRUCT cs甫 荐沥窍咯 咯扁俊辑
  70. // Window 努贰胶 肚绰 胶鸥老阑 荐沥钦聪促.
  71. return TRUE;
  72. }
  73. // CMainFrame 柳窜
  74. #ifdef _DEBUG
  75. void CMainFrame::AssertValid() const
  76. {
  77. CMDIFrameWnd::AssertValid();
  78. }
  79. void CMainFrame::Dump(CDumpContext& dc) const
  80. {
  81. CMDIFrameWnd::Dump(dc);
  82. }
  83. #endif //_DEBUG
  84. // CMainFrame 皋矫瘤 贸府扁
  85. void CMainFrame::OnDestroy()
  86. {
  87. CMDIFrameWnd::OnDestroy();
  88. int nCount = m_aryDlg.GetCount();
  89. for(int i=0;i<nCount;i++)
  90. {
  91. CDialog1* pDlg = (CDialog1*)m_aryDlg.GetAt(i);
  92. if(pDlg)
  93. pDlg->DestroyWindow();
  94. }
  95. }
  96. void CMainFrame::OnViewDialog()
  97. {
  98. CRect rcMonitor;
  99. for(int i=0;i<theApp.m_infoMonitor.aryMonitors.GetCount();i++)
  100. {
  101. CDialog1* pDlg = new CDialog1;
  102. pDlg->m_MonitorInfoEx=((MONITORINFOEX)theApp.m_infoMonitor.aryMonitors.GetAt(i));
  103. rcMonitor=pDlg->m_MonitorInfoEx.rcMonitor;
  104. pDlg->Create(this);
  105. pDlg->MoveWindow(rcMonitor);
  106. pDlg->ShowWindow(SW_SHOW);
  107. m_aryDlg.Add(pDlg);
  108. }
  109. }