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.

189 lines
4.6 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 = _T("");
  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
  93. CNewQueryDlg::OnOK()
  94. {
  95. INT iPrevLength = 0;
  96. ResourceStateManager rsm;
  97. if ( UpdateData (TRUE) ) {
  98. iPrevLength = m_strName.GetLength();
  99. m_strName.TrimLeft();
  100. m_strName.TrimRight();
  101. if ( iPrevLength != m_strName.GetLength() ) {
  102. SetDlgItemText ( IDC_NEWQ_NAME_EDIT, m_strName );
  103. }
  104. if (m_strName.GetLength() == 0) {
  105. // need a name
  106. MessageBeep(MB_ICONEXCLAMATION);
  107. (GetDlgItem(IDC_NEWQ_NAME_EDIT))->SetFocus();
  108. } else {
  109. if ( !FileNameIsValid ( &m_strName ) ) {
  110. CString cstrTitle,cstrMsg;
  111. cstrTitle.LoadString(IDS_PROJNAME);
  112. cstrMsg.LoadString (IDS_ERRMSG_INVALIDCHAR);
  113. MessageBox(
  114. cstrMsg,
  115. cstrTitle,
  116. MB_OK| MB_ICONERROR);
  117. (GetDlgItem(IDC_NEWQ_NAME_EDIT))->SetFocus();
  118. } else {
  119. CDialog::OnOK();
  120. }
  121. }
  122. }
  123. }
  124. BOOL
  125. CNewQueryDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  126. {
  127. if ( pHelpInfo->iCtrlId >= IDC_NEWQ_FIRST_HELP_CTRL_ID ||
  128. pHelpInfo->iCtrlId == IDOK ||
  129. pHelpInfo->iCtrlId == IDCANCEL ) {
  130. InvokeWinHelp(WM_HELP, NULL, (LPARAM)pHelpInfo, m_strHelpFilePath, s_aulHelpIds);
  131. }
  132. return TRUE;
  133. }
  134. void
  135. CNewQueryDlg::OnContextMenu(CWnd* pWnd, CPoint /* point */)
  136. {
  137. InvokeWinHelp(WM_CONTEXTMENU, (WPARAM)(pWnd->m_hWnd), NULL, m_strHelpFilePath, s_aulHelpIds);
  138. return;
  139. }
  140. DWORD
  141. CNewQueryDlg::SetContextHelpFilePath( const CString& rstrPath )
  142. {
  143. DWORD dwStatus = ERROR_SUCCESS;
  144. MFC_TRY
  145. m_strHelpFilePath = rstrPath;
  146. MFC_CATCH_DWSTATUS
  147. return dwStatus;
  148. }