MINIFRM.CPP
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:3k
源码类别:

Windows编程

开发平台:

Visual C++

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #include "shapeobj.h"
  12. #include "resource.h"
  13. #include "colorpge.h"
  14. #include "stylepge.h"
  15. #include "propsht2.h"
  16. #include "minifrm.h"
  17. #include "mainfrm.h"
  18. BEGIN_MESSAGE_MAP(CShapePropSheetFrame, CMiniFrameWnd)
  19. //{{AFX_MSG_MAP(CShapePropSheetFrame)
  20. ON_WM_CREATE()
  21. ON_WM_CLOSE()
  22. ON_WM_SETFOCUS()
  23. ON_WM_ACTIVATE()
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. CShapePropSheetFrame::CShapePropSheetFrame()
  27. {
  28. m_pModelessShapePropSheet = NULL;
  29. }
  30. int CShapePropSheetFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  31. {
  32. if (CMiniFrameWnd::OnCreate(lpCreateStruct) == -1)
  33. return -1;
  34. m_pModelessShapePropSheet = new CModelessShapePropSheet(this);
  35. if (!m_pModelessShapePropSheet->Create(this,
  36. WS_CHILD | WS_VISIBLE, 0))
  37. {
  38. delete m_pModelessShapePropSheet;
  39. m_pModelessShapePropSheet = NULL;
  40. return -1;
  41. }
  42. // Resize the mini frame so that it fits around the child property
  43. // sheet.
  44. CRect rectClient, rectWindow;
  45. m_pModelessShapePropSheet->GetWindowRect(rectClient);
  46. rectWindow = rectClient;
  47. // CMiniFrameWnd::CalcWindowRect adds the extra width and height
  48. // needed from the mini frame.
  49. CalcWindowRect(rectWindow);
  50. SetWindowPos(NULL, rectWindow.left, rectWindow.top,
  51. rectWindow.Width(), rectWindow.Height(),
  52. SWP_NOZORDER | SWP_NOACTIVATE);
  53. m_pModelessShapePropSheet->SetWindowPos(NULL, 0, 0,
  54. rectClient.Width(), rectClient.Height(),
  55. SWP_NOZORDER | SWP_NOACTIVATE);
  56. return 0;
  57. }
  58. void CShapePropSheetFrame::OnClose()
  59. {
  60. // Instead of closing the modeless property sheet, just hide it.
  61. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  62. pMainFrame->HideModelessPropSheet();
  63. }
  64. void CShapePropSheetFrame::OnSetFocus(CWnd* /*pOldWnd*/)
  65. {
  66. // Forward focus to the embedded property sheet
  67. ASSERT_VALID(m_pModelessShapePropSheet);
  68. m_pModelessShapePropSheet->SetFocus();
  69. }
  70. void CShapePropSheetFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
  71. {
  72. CMiniFrameWnd::OnActivate(nState, pWndOther, bMinimized);
  73. // Forward any WM_ACTIVATEs to the property sheet...
  74. // Like the dialog manager itself, it needs them to save/restore the focus.
  75. ASSERT_VALID(m_pModelessShapePropSheet);
  76. // Use GetCurrentMessage to get unmodified message data.
  77. const MSG* pMsg = GetCurrentMessage();
  78. ASSERT(pMsg->message == WM_ACTIVATE);
  79. m_pModelessShapePropSheet->SendMessage(pMsg->message, pMsg->wParam,
  80. pMsg->lParam);
  81. }