home *** CD-ROM | disk | FTP | other *** search
/ ftp.funduc.com / 2014.08.ftp.funduc.com.tar / ftp.funduc.com / fshedcode-072212.zip / GotoDlg.cpp < prev    next >
C/C++ Source or Header  |  2010-09-13  |  3KB  |  91 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //    License (GPLv2+):
  3. //    This program is free software; you can redistribute it and/or modify
  4. //    it under the terms of the GNU General Public License as published by
  5. //    the Free Software Foundation; either version 2 of the License, or
  6. //    (at your option) any later version.
  7. //
  8. //    This program is distributed in the hope that it will be useful, but
  9. //    WITHOUT ANY WARRANTY; without even the implied warranty of
  10. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11. //    General Public License for more details.
  12. //
  13. //    You should have received a copy of the GNU General Public License
  14. //    along with this program; if not, write to the Free Software
  15. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. /////////////////////////////////////////////////////////////////////////////
  17.  
  18. #include "stdafx.h"
  19. #include "Fshed.h"
  20. #include "GotoDlg.h"
  21.  
  22. // CGotoDlg dialog
  23.  
  24. IMPLEMENT_DYNAMIC(CGotoDlg, CDialog)
  25.  
  26. CGotoDlg::CGotoDlg(CWnd* pParent /*=NULL*/)
  27.     : CDialog(CGotoDlg::IDD, pParent)
  28.     , m_strOffset(_T(""))
  29. {
  30.     m_nOffset = 0;
  31.     m_bRelative = true;
  32. }
  33.  
  34. CGotoDlg::~CGotoDlg()
  35. {
  36. }
  37.  
  38. void CGotoDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40.     CDialog::DoDataExchange(pDX);
  41.     //{{AFX_DATA_MAP(CSelectBlockDlg)
  42.     DDX_Text(pDX, IDC_OFFSET_ED, m_strOffset);
  43.     //}}AFX_DATA_MAP
  44.     if (pDX->m_bSaveAndValidate)
  45.     {
  46.         bool bPos = true;
  47.         if (m_strOffset.GetLength())
  48.         {
  49.             m_strOffset = m_strOffset.Trim();
  50.             if (m_strOffset[0] == '-')
  51.             {
  52.                 bPos = false;
  53.                 m_bRelative = true;
  54.                 m_strOffset = m_strOffset.Mid(1);
  55.             }
  56.             else if (m_strOffset[0] == '+')
  57.             {
  58.                 m_bRelative = true;
  59.                 m_strOffset = m_strOffset.Mid(1);
  60.             }
  61.         }
  62.         if (_stscanf(m_strOffset, _T("x%x"), &m_nOffset) == 0)
  63.         {
  64.             if (_stscanf(m_strOffset, _T("%d"), &m_nOffset) == 0)
  65.             {
  66.                 AfxMessageBox (IDS_ERR_INV_OFFSET);
  67.                 pDX->Fail();
  68.             }
  69.         }
  70.         if (m_bRelative && !bPos)
  71.             m_nOffset = -m_nOffset;
  72.     }
  73. }
  74.  
  75.  
  76. BEGIN_MESSAGE_MAP(CGotoDlg, CDialog)
  77. END_MESSAGE_MAP()
  78.  
  79.  
  80. // CGotoDlg message handlers
  81.  
  82. BOOL CGotoDlg::OnInitDialog() 
  83. {
  84.     m_strOffset.Format(_T("x%x"), m_nOffset);
  85.  
  86.     CDialog::OnInitDialog();
  87.     
  88.     return TRUE;  // return TRUE unless you set the focus to a control
  89.                   // EXCEPTION: OCX Property Pages should return FALSE
  90. }
  91.