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

Windows编程

开发平台:

Visual C++

  1. // propsht.cpp : implementation of the CModalShapePropSheet 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 "propdlg.h"
  14. #include "resource.h"
  15. #include "shapeobj.h"
  16. #include "colorpge.h"
  17. #include "stylepge.h"
  18. #include "preview.h"
  19. #include "propsht.h"
  20. IMPLEMENT_DYNAMIC(CModalShapePropSheet, CPropertySheet)
  21. BEGIN_MESSAGE_MAP(CModalShapePropSheet, CPropertySheet)
  22. //{{AFX_MSG_MAP(CModalShapePropSheet)
  23. ON_COMMAND(ID_APPLY_NOW, OnApplyNow)
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. CModalShapePropSheet::CModalShapePropSheet(CWnd* pWndParent)
  27. : CPropertySheet(AFX_IDS_APP_TITLE, pWndParent)
  28. {
  29. AddPage(&m_stylePage);
  30. AddPage(&m_colorPage);
  31. }
  32. BOOL CModalShapePropSheet::OnInitDialog()
  33. {
  34. BOOL bResult = CPropertySheet::OnInitDialog();
  35. // add the preview window to the property sheet.
  36. CRect rectWnd;
  37. GetWindowRect(rectWnd);
  38. SetWindowPos(NULL, 0, 0,
  39. rectWnd.Width() + 100,
  40. rectWnd.Height(),
  41. SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
  42. CRect rectPreview(rectWnd.Width() + 25, 25,
  43. rectWnd.Width()+75, 75);
  44. m_wndPreview.Create(NULL, NULL, WS_CHILD|WS_VISIBLE,
  45. rectPreview, this, 0x1000);
  46. CenterWindow();
  47. return bResult;
  48. }
  49. void CModalShapePropSheet::SetSheetPropsFromShape(CShape* pShape)
  50. {
  51. m_stylePage.m_nShapeStyle = pShape->m_shapestyle;
  52. m_stylePage.SetModified(FALSE);
  53. m_colorPage.m_nColor = pShape->m_shapecolor;
  54. m_colorPage.SetModified(FALSE);
  55. // Reflect the new shape properties in the controls of the
  56. // currently active property page.
  57. GetActivePage()->UpdateData(FALSE);
  58. UpdateShapePreview();
  59. }
  60. void CModalShapePropSheet::SetShapePropsFromSheet(CShape* pShape)
  61. {
  62. pShape->m_shapecolor = m_colorPage.m_nColor;
  63. pShape->m_shapestyle = (SHAPE_STYLE)m_stylePage.m_nShapeStyle;
  64. m_colorPage.SetModified(FALSE);
  65. m_stylePage.SetModified(FALSE);
  66. }
  67. void CModalShapePropSheet::UpdateShapePreview()
  68. {
  69. m_wndPreview.Invalidate();
  70. m_wndPreview.UpdateWindow();
  71. }
  72. void CModalShapePropSheet::OnApplyNow()
  73. {
  74. Default();
  75. CFrameWnd* pFrameWnd = STATIC_DOWNCAST(CFrameWnd, AfxGetMainWnd());
  76. CView* pView = pFrameWnd->GetActiveFrame()->GetActiveView();
  77. pView->SendMessage(WM_USER_CHANGE_OBJECT_PROPERTIES, 0, 0);
  78. m_stylePage.SetModified(FALSE);
  79. m_colorPage.SetModified(FALSE);
  80. SendMessage(PSM_CANCELTOCLOSE);
  81. }