Leaked source code of windows server 2003
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.

188 lines
4.8 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. newqdlg.cpp
  5. Abstract:
  6. Implementation of the new log/alert creation dialog box.
  7. --*/
  8. #include "stdafx.h"
  9. #include "smlogcfg.h"
  10. #include "smcfghlp.h"
  11. #include "NewQDlg.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. USE_HANDLE_MACROS("SMLOGCFG(newqdlg.cpp)");
  18. static ULONG
  19. s_aulHelpIds[] =
  20. {
  21. IDC_NEWQ_NAME_EDIT, IDH_NEWQ_NAME_EDIT,
  22. 0,0
  23. };
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CNewQueryDlg dialog
  26. void CNewQueryDlg::InitAfxData ()
  27. {
  28. //{{AFX_DATA_INIT(CNewQueryDlg)
  29. m_strName = L"";
  30. //}}AFX_DATA_INIT
  31. }
  32. CNewQueryDlg::CNewQueryDlg(CWnd* pParent /*=NULL*/, BOOL bLogQuery)
  33. : CDialog(CNewQueryDlg::IDD, pParent)
  34. {
  35. EnableAutomation();
  36. InitAfxData ();
  37. m_bLogQuery = bLogQuery;
  38. }
  39. void CNewQueryDlg::OnFinalRelease()
  40. {
  41. // When the last reference for an automation object is released
  42. // OnFinalRelease is called. The base class will automatically
  43. // deletes the object. Add additional cleanup required for your
  44. // object before calling the base class.
  45. CDialog::OnFinalRelease();
  46. }
  47. void CNewQueryDlg::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CDialog::DoDataExchange(pDX);
  50. //{{AFX_DATA_MAP(CNewQueryDlg)
  51. DDX_Text(pDX, IDC_NEWQ_NAME_EDIT, m_strName);
  52. DDV_MaxChars(pDX, m_strName, (SLQ_MAX_LOG_NAME_LEN));
  53. //}}AFX_DATA_MAP
  54. }
  55. BEGIN_MESSAGE_MAP(CNewQueryDlg, CDialog)
  56. //{{AFX_MSG_MAP(CNewQueryDlg)
  57. ON_WM_HELPINFO()
  58. ON_WM_CONTEXTMENU()
  59. //}}AFX_MSG_MAP
  60. END_MESSAGE_MAP()
  61. BEGIN_DISPATCH_MAP(CNewQueryDlg, CDialog)
  62. //{{AFX_DISPATCH_MAP(CNewQueryDlg)
  63. // NOTE - the ClassWizard will add and remove mapping macros here.
  64. //}}AFX_DISPATCH_MAP
  65. END_DISPATCH_MAP()
  66. // Note: we add support for IID_INewQueryDlg to support typesafe binding
  67. // from VBA. This IID must match the GUID that is attached to the
  68. // dispinterface in the .ODL file.
  69. // {4D4C90C3-C5A3-11D1-BF9B-00C04F94A83A}
  70. static const IID IID_INewQueryDlg =
  71. { 0x4d4c90c3, 0xc5a3, 0x11d1, { 0xbf, 0x9b, 0x0, 0xc0, 0x4f, 0x94, 0xa8, 0x3a } };
  72. BEGIN_INTERFACE_MAP(CNewQueryDlg, CDialog)
  73. INTERFACE_PART(CNewQueryDlg, IID_INewQueryDlg, Dispatch)
  74. END_INTERFACE_MAP()
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CNewQueryDlg message handlers
  77. BOOL CNewQueryDlg::OnInitDialog()
  78. {
  79. CDialog::OnInitDialog();
  80. ResourceStateManager rsm;
  81. if (!m_bLogQuery) {
  82. CString csCaption;
  83. csCaption.LoadString (IDS_CREATE_NEW_ALERT);
  84. SetWindowText (csCaption);
  85. }
  86. // set the focus to the name edit
  87. GetDlgItem(IDC_NEWQ_NAME_EDIT)->SetFocus();
  88. SendDlgItemMessage(IDC_NEWQ_NAME_EDIT,EM_SETSEL,0,-1);
  89. return FALSE; // return TRUE unless you set the focus to a control
  90. // EXCEPTION: OCX Property Pages should return FALSE
  91. }
  92. void CNewQueryDlg::OnOK()
  93. {
  94. INT iPrevLength = 0;
  95. ResourceStateManager rsm;
  96. if ( UpdateData (TRUE) ) {
  97. iPrevLength = m_strName.GetLength();
  98. m_strName.TrimLeft();
  99. m_strName.TrimRight();
  100. if ( iPrevLength != m_strName.GetLength() ) {
  101. SetDlgItemText ( IDC_NEWQ_NAME_EDIT, m_strName );
  102. }
  103. if (m_strName.GetLength() == 0) {
  104. // need a name
  105. MessageBeep(MB_ICONEXCLAMATION);
  106. (GetDlgItem(IDC_NEWQ_NAME_EDIT))->SetFocus();
  107. } else {
  108. if ( !FileNameIsValid ( &m_strName ) ) {
  109. CString cstrTitle,cstrMsg;
  110. cstrTitle.LoadString(IDS_PROJNAME);
  111. cstrMsg.LoadString (IDS_ERRMSG_INVALIDCHAR);
  112. MessageBox(
  113. cstrMsg,
  114. cstrTitle,
  115. MB_OK| MB_ICONERROR);
  116. (GetDlgItem(IDC_NEWQ_NAME_EDIT))->SetFocus();
  117. } else {
  118. CDialog::OnOK();
  119. }
  120. }
  121. }
  122. }
  123. BOOL
  124. CNewQueryDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  125. {
  126. if ( pHelpInfo->iCtrlId >= IDC_NEWQ_FIRST_HELP_CTRL_ID ||
  127. pHelpInfo->iCtrlId == IDOK ||
  128. pHelpInfo->iCtrlId == IDCANCEL ) {
  129. InvokeWinHelp(WM_HELP, NULL, (LPARAM)pHelpInfo, m_strHelpFilePath, s_aulHelpIds);
  130. }
  131. return TRUE;
  132. }
  133. void
  134. CNewQueryDlg::OnContextMenu(CWnd* pWnd, CPoint /* point */)
  135. {
  136. InvokeWinHelp(WM_CONTEXTMENU, (WPARAM)(pWnd->m_hWnd), NULL, m_strHelpFilePath, s_aulHelpIds);
  137. return;
  138. }
  139. DWORD
  140. CNewQueryDlg::SetContextHelpFilePath( const CString& rstrPath )
  141. {
  142. DWORD dwStatus = ERROR_SUCCESS;
  143. MFC_TRY
  144. m_strHelpFilePath = rstrPath;
  145. MFC_CATCH_DWSTATUS
  146. return dwStatus;
  147. }