AddIPDlg.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /****************************************************************/
  2. /* */
  3. /* AddIPDlg.cpp */
  4. /* */
  5. /* Implementation of the CAddIPDlg class. */
  6. /* This class is a part of the FTP Server Application */
  7. /* */
  8. /* Programmed by LYFZ van der Meer */
  9. /* Copyright LYFZ Software Solutions 2002 */
  10. /* http://www.LYFZvandermeer.nl */
  11. /* */
  12. /* Last updated: 10 july 2002 */
  13. /* */
  14. /****************************************************************/
  15. #include "stdafx.h"
  16. #include "DBServer.h"
  17. #include "theDBServer.h"
  18. #include "AddIPDlg.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. CAddIPDlg::CAddIPDlg(CWnd* pParent /*=NULL*/)
  25. : CDialog(CAddIPDlg::IDD, pParent)
  26. {
  27. //{{AFX_DATA_INIT(CAddIPDlg)
  28. m_strIPaddress = _T("");
  29. //}}AFX_DATA_INIT
  30. }
  31. void CAddIPDlg::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CDialog::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CAddIPDlg)
  35. DDX_Text(pDX, IDC_IPADDRESS, m_strIPaddress);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(CAddIPDlg, CDialog)
  39. //{{AFX_MSG_MAP(CAddIPDlg)
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /********************************************************************/
  43. /* */
  44. /* Function name : OnInitDialog */
  45. /* Description : Initialize dialog */
  46. /* */
  47. /********************************************************************/
  48. BOOL CAddIPDlg::OnInitDialog()
  49. {
  50. CDialog::OnInitDialog();
  51. if (!m_strTitle.IsEmpty())
  52. SetWindowText(m_strTitle);
  53. // ip address can be 255.255.255.255 = 15 chars max.
  54. ((CEdit *)GetDlgItem(IDC_IPADDRESS))->SetLimitText(15);
  55. CenterWindow();
  56. return TRUE;
  57. }
  58. /********************************************************************/
  59. /* */
  60. /* Function name : PreTranslateMessage */
  61. /* Description : Only accept numeric characters, decimal point */
  62. /* separators, backspace and tabs. */
  63. /* */
  64. /********************************************************************/
  65. BOOL CAddIPDlg::PreTranslateMessage(MSG* pMsg)
  66. {
  67. if (pMsg->message == WM_CHAR && pMsg->hwnd == ::GetDlgItem(m_hWnd, IDC_IPADDRESS))
  68. {
  69. TCHAR nChar = (TCHAR)pMsg->wParam;
  70. if ((IsCharAlphaNumeric(nChar) && !IsCharAlpha(nChar)) ||
  71. nChar == '.' || nChar == '\b' || nChar == '\t' || nChar == '*')
  72. {
  73. return CDialog::PreTranslateMessage(pMsg);
  74. }
  75. else
  76. {
  77. // eat character
  78. return TRUE;
  79. }
  80. }
  81. return CDialog::PreTranslateMessage(pMsg);
  82. }