Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
1.8 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. // MofDlg.cpp : implementation file
  8. //
  9. #include "stdafx.h"
  10. #include "wmitest.h"
  11. #include "MofDlg.h"
  12. #include "WMITestDoc.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMofDlg dialog
  20. CMofDlg::CMofDlg(CWnd* pParent /*=NULL*/)
  21. : CDialog(CMofDlg::IDD, pParent)
  22. {
  23. //{{AFX_DATA_INIT(CMofDlg)
  24. // NOTE: the ClassWizard will add member initialization here
  25. //}}AFX_DATA_INIT
  26. }
  27. void FixCRs(CString &strText)
  28. {
  29. CString strTemp = strText;
  30. strText = "";
  31. while (strTemp.GetLength())
  32. {
  33. int iWhere = strTemp.Find('\n');
  34. if (iWhere == -1)
  35. {
  36. strText += strTemp;
  37. strTemp = "";
  38. }
  39. else
  40. {
  41. strText += strTemp.Left(iWhere);
  42. strText += "\r\n";
  43. strTemp = strTemp.Mid(iWhere + 1);
  44. }
  45. }
  46. }
  47. void CMofDlg::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CDialog::DoDataExchange(pDX);
  50. //{{AFX_DATA_MAP(CMofDlg)
  51. // NOTE: the ClassWizard will add DDX and DDV calls here
  52. //}}AFX_DATA_MAP
  53. if (!pDX->m_bSaveAndValidate)
  54. {
  55. BSTR bstrText;
  56. HRESULT hr;
  57. if (SUCCEEDED(hr = m_pObj->GetObjectText(
  58. 0,
  59. &bstrText)))
  60. {
  61. CString strText = bstrText;
  62. FixCRs(strText);
  63. SetDlgItemText(IDC_MOF, strText);
  64. SysFreeString(bstrText);
  65. }
  66. else
  67. {
  68. CWMITestDoc::DisplayWMIErrorBox(hr);
  69. OnCancel();
  70. }
  71. }
  72. }
  73. BEGIN_MESSAGE_MAP(CMofDlg, CDialog)
  74. //{{AFX_MSG_MAP(CMofDlg)
  75. // NOTE: the ClassWizard will add message map macros here
  76. //}}AFX_MSG_MAP
  77. END_MESSAGE_MAP()
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CMofDlg message handlers