SampleView.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:4k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // SampleView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "SkinSDISample.h"
  5. #include "SampleView.h"
  6. #include "Mainfrm.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CSampleView
  14. IMPLEMENT_DYNCREATE(CSampleView, CFormView)
  15. CSampleView::CSampleView()
  16. : CFormView(CSampleView::IDD)
  17. {
  18. //{{AFX_DATA_INIT(CSampleView)
  19. m_nSkin = 0;
  20. m_nTheme = 1;
  21. m_strFind = _T("");
  22. m_bMatchCase = FALSE;
  23. m_bMatchWord = FALSE;
  24. m_bFlat = FALSE;
  25. m_bShowGripper = TRUE;
  26. //}}AFX_DATA_INIT
  27. }
  28. CSampleView::~CSampleView()
  29. {
  30. }
  31. void CSampleView::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CFormView::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CSampleView)
  35. DDX_Radio(pDX, IDC_RADIO_LE5, m_nSkin);
  36. DDX_Radio(pDX, IDC_RADIO_OFFICE2003, m_nTheme);
  37. DDX_Text(pDX, IDC_EDIT_FIND, m_strFind);
  38. DDX_Check(pDX, IDC_CHECK_MATCHCASE, m_bMatchCase);
  39. DDX_Check(pDX, IDC_CHECK_MATCHWORD, m_bMatchWord);
  40. DDX_Check(pDX, IDC_CHECK_FLAT, m_bFlat);
  41. DDX_Check(pDX, IDC_CHECK_GRIPPER, m_bShowGripper);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CSampleView, CFormView)
  45. //{{AFX_MSG_MAP(CSampleView)
  46. ON_BN_CLICKED(IDC_BUTTON_FIND, OnButtonFind)
  47. ON_BN_CLICKED(IDC_BUTTON_COLORDIALOG, OnButtonColordialog)
  48. ON_BN_CLICKED(IDC_BUTTON_FONTDIALOG, OnButtonFontdialog)
  49. ON_BN_CLICKED(IDC_BUTTON_PRINTDIALOG, OnButtonPrintdialog)
  50. ON_BN_CLICKED(IDC_BUTTON_OPENDIALOG, OnButtonOpendialog)
  51. ON_BN_CLICKED(IDC_RADIO_LE5, OnSkinChanged)
  52. ON_BN_CLICKED(IDC_RADIO_OFFICE2003, OnThemeChanged)
  53. ON_BN_CLICKED(IDC_CHECK_FLAT, OnThemeChanged)
  54. ON_BN_CLICKED(IDC_RADIO_ITUNES, OnSkinChanged)
  55. ON_BN_CLICKED(IDC_RADIO_DEFAULT, OnSkinChanged)
  56. ON_BN_CLICKED(IDC_RADIO_WINXP, OnThemeChanged)
  57. ON_EN_CHANGE(IDC_EDIT_FIND, OnChangeEditFind)
  58. ON_BN_CLICKED(IDC_CHECK_GRIPPER, OnCheckGripper)
  59. //}}AFX_MSG_MAP
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CSampleView diagnostics
  63. #ifdef _DEBUG
  64. void CSampleView::AssertValid() const
  65. {
  66. CFormView::AssertValid();
  67. }
  68. void CSampleView::Dump(CDumpContext& dc) const
  69. {
  70. CFormView::Dump(dc);
  71. }
  72. #endif //_DEBUG
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CSampleView message handlers
  75. void CSampleView::OnInitialUpdate() 
  76. {
  77. CFormView::OnInitialUpdate();
  78. }
  79. void CSampleView::OnButtonFind() 
  80. {
  81. UpdateData();
  82. CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd();
  83. CRichEditView* pView = (CRichEditView*)pWnd->m_wndSplitter.GetPane(0, 1);
  84. if (!pView->FindText(m_strFind, m_bMatchCase, m_bMatchWord))
  85. {
  86. pView->TextNotFound(m_strFind);
  87. }
  88. }
  89. void CSampleView::OnChangeEditFind() 
  90. {
  91. UpdateData();
  92. GetDlgItem(IDC_BUTTON_FIND)->EnableWindow(!m_strFind.IsEmpty());
  93. }
  94. void CSampleView::OnButtonColordialog() 
  95. {
  96. CColorDialog cd;
  97. cd.DoModal();
  98. }
  99. void CSampleView::OnButtonFontdialog() 
  100. {
  101. CFontDialog fd;
  102. fd.DoModal();
  103. }
  104. void CSampleView::OnButtonPrintdialog() 
  105. {
  106. CPrintDialog pd(TRUE);
  107. pd.DoModal();
  108. }
  109. void CSampleView::OnButtonOpendialog() 
  110. {
  111. CFileDialog fd(TRUE);
  112. if (XTOSVersionInfo()->IsWin2KOrGreater() && sizeof(OPENFILENAME) < 88 && fd.m_ofn.lStructSize < 88)
  113. {
  114. // Windows 2000 version of OPENFILENAME has three extra members,
  115. // this was copied from newer version of commdlg.h...
  116. struct OPENFILENAMEEX
  117. {
  118. void*  pvReserved; // 4 bytes
  119. DWORD  dwReserved; // 4 bytes
  120. DWORD  FlagsEx;    // 4 bytes
  121. };
  122. fd.m_ofn.lStructSize += sizeof(OPENFILENAMEEX); // should equal an additional 12 bytes;
  123. }
  124. fd.DoModal();
  125. }
  126. void CSampleView::OnSkinChanged() 
  127. {
  128. UpdateData();
  129. CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd();
  130. pWnd->LoadSkin(m_nSkin);
  131. }
  132. void CSampleView::OnThemeChanged() 
  133. {
  134. UpdateData();
  135. CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd();
  136. pWnd->SetTheme(m_nTheme, m_bFlat);
  137. }
  138. void CSampleView::OnCheckGripper()
  139. {
  140. UpdateData();
  141. CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd();
  142. pWnd->GetCommandBars()->GetAt(0)->SetShowGripper(m_bShowGripper);
  143. pWnd->GetCommandBars()->GetAt(1)->SetShowGripper(m_bShowGripper);
  144. pWnd->GetCommandBars()->RedrawCommandBars();
  145. }
  146.