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.

103 lines
2.4 KiB

  1. #pragma once
  2. #include "UIUtils.h"
  3. class CCommandDlg : public CDialogImpl<CCommandDlg>
  4. {
  5. public:
  6. enum { IDD = IDD_POSTPROCESS_CMD };
  7. static const CMD_MAX_LEN = 2 * 1024;
  8. BEGIN_MSG_MAP(CMyDialog)
  9. MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
  10. COMMAND_ID_HANDLER( IDOK, OnOK )
  11. COMMAND_ID_HANDLER( IDCANCEL, OnCancel )
  12. COMMAND_CODE_HANDLER( EN_CHANGE, OnCmdChange )
  13. END_MSG_MAP()
  14. CCommandDlg(void)
  15. {
  16. m_bIgnoreErrors = false;
  17. m_dwTimeout = 0;
  18. }
  19. LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/ )
  20. {
  21. VERIFY( SetDlgItemText( IDC_CMDTEXT, m_strText ) );
  22. Edit_LimitText( GetDlgItem( IDC_CMDTEXT ), CMD_MAX_LEN );
  23. Edit_LimitText( GetDlgItem( IDC_TIMEOUT ), 8 );
  24. Button_SetCheck( GetDlgItem( IDC_IGNOREERRORS ), m_bIgnoreErrors );
  25. SetDlgItemInt( IDC_TIMEOUT, m_dwTimeout, FALSE );
  26. ::EnableWindow( GetDlgItem( IDOK ), m_strText.GetLength() > 0 );
  27. return 1;
  28. }
  29. LRESULT OnOK( WORD wNotifyCode, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled )
  30. {
  31. m_bIgnoreErrors = Button_GetCheck( GetDlgItem( IDC_IGNOREERRORS ) ) != FALSE;
  32. GetDlgItemText( IDC_CMDTEXT, m_strText.GetBuffer( CMD_MAX_LEN + 1 ), CMD_MAX_LEN );
  33. m_strText.ReleaseBuffer();
  34. BOOL bTranslated = FALSE;
  35. m_dwTimeout = GetDlgItemInt( IDC_TIMEOUT, &bTranslated, FALSE );
  36. if ( !bTranslated )
  37. {
  38. UIUtils::MessageBox( m_hWnd, IDS_E_NOTNUMERIC, IDS_APPTITLE, MB_OK | MB_ICONERROR );
  39. ::SetFocus( GetDlgItem( IDC_TIMEOUT ) );
  40. }
  41. else
  42. {
  43. EndDialog( IDOK );
  44. }
  45. return 0;
  46. }
  47. LRESULT OnCancel( WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/ )
  48. {
  49. EndDialog( IDCANCEL );
  50. return 0;
  51. }
  52. LRESULT OnCmdChange( WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& bHandled )
  53. {
  54. if ( wID != IDC_CMDTEXT )
  55. {
  56. bHandled = FALSE;
  57. return 0;
  58. }
  59. CEdit ctrl( hWndCtl );
  60. ::EnableWindow( GetDlgItem( IDOK ), ctrl.GetWindowTextLength() > 0 );
  61. return 0;
  62. }
  63. public:
  64. bool m_bIgnoreErrors;
  65. DWORD m_dwTimeout;
  66. CString m_strText;
  67. };