
/***************************************************************************
**
**    $Header:   D:/ECB2S/SRC/LOG/DSMEDIT1.CPP   1.2.1.5   17 Apr 1997 15:48:18   ZJRD  $
**
**    $Log:   D:/ECB2S/SRC/LOG/DSMEDIT1.CPP  $
** 
**    Rev 1.2.1.5   17 Apr 1997 15:48:18   ZJRD
** No change.
** 
**    Rev 1.2.1.4   16 Apr 1997 10:19:34   ZJRD
** No change.
** 
**    Rev 1.2.1.3   10 Apr 1997 15:30:58   ZJRD
** 2.09F
** 
**    Rev 1.2.1.1   03 Apr 1997 15:11:52   ZJRD
** 2.09E
** 
**    Rev 1.2.1.0   28 Mar 1997 10:16:54   ZJRD
** easy pack sld 2.09d
** 
**    Rev 1.1   19 Mar 1997 11:28:02   ZJRD
** No change.
** 
**    Rev 1.0   12 Mar 1997 14:45:54   ZJRD
** Initial revision.
** 
**    Rev 1.7.1.0.1.2   09 Dec 1996 10:15:04   ZJRD
** EasyPack/SLD Version 2.0P
** 
**    Rev 1.7.1.0.1.0   11 Nov 1996 12:58:20   ZJRD
** EasyPack/SLD Version 2.01
** 
**    Rev 1.7.1.4   09 Sep 1996 13:15:42   ZJRD
** No change.
** 
**    Rev 1.7.1.3   05 Sep 1996 11:27:16   ZJRD
** No change.
** 
**    Rev 1.7.1.2   02 Sep 1996 09:54:22   ZJRD
** No change.
** 
**    Rev 1.7.1.1   28 Aug 1996 15:48:34   ZJRD
** No change.
** 
**    Rev 1.7.1.0   12 Aug 1996 10:53:02   ZJRD
** EasyPack/SLD Version 1.98
** 
**    Rev 1.5   05 Jun 1996 14:56:18   ZJRD
** No change.
** 
**    Rev 1.4   29 May 1996 09:36:24   ZJRD
** No change.
** 
**    Rev 1.3   16 May 1996 09:09:02   ZJRD
** No change.
** 
**    Rev 1.2   10 May 1996 09:08:40   ZJRD
** No change.
** 
**    Rev 1.1   02 May 1996 10:26:16   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.31   18 Apr 1996 12:54:08   Shirley
** No change.
** 
**    Rev 1.30   12 Apr 1996 10:36:14   Shirley
** EasyPack/SLD Version 1.90
** 
**    Rev 1.28   15 Feb 1996 08:57:30   Shirley
** No change.
** 
**    Rev 1.27   12 Feb 1996 14:10:26   Shirley
** No change.
** 
**    Rev 1.26   06 Feb 1996 15:36:50   Shirley
** No change.
** 
**    Rev 1.25   06 Feb 1996 13:51:04   Shirley
** No change.
** 
**    Rev 1.24   01 Feb 1996 10:12:20   Shirley
** EasyPack/SLD Version 0.35b
** 
**    Rev 1.23   26 Jan 1996 09:12:04   Shirley
** No change.
** 
**    Rev 1.22   25 Jan 1996 13:12:44   Shirley
** No change.
** 
**    Rev 1.21   24 Jan 1996 10:36:22   Shirley
** No change.
** 
**    Rev 1.20   23 Jan 1996 11:24:48   Shirley
** No change.
** 
**    Rev 1.19   18 Jan 1996 10:09:10   Shirley
** No change.
** 
**    Rev 1.18   15 Jan 1996 16:12:10   Shirley
** No change.
** 
**    Rev 1.17   04 Jan 1996 11:14:40   Shirley
** No change.
** 
**    Rev 1.16   30 Nov 1995 09:09:52   Shirley
** No change.
** 
**    Rev 1.15   28 Nov 1995 15:30:42   Shirley
** No change.
** 
**    Rev 1.14   21 Nov 1995 11:20:22   Shirley
** No change.
** 
**    Rev 1.13   13 Nov 1995 09:23:04   Shirley
** No change.
** 
**    Rev 1.12   12 Nov 1995 11:32:06   Shirley
** EasyPack/SLD Version 0.24
** 
**    Rev 1.11   08 Nov 1995 16:34:12   Shirley
** No change.
** 
**    Rev 1.10   08 Nov 1995 12:44:06   Shirley
** EasyPack/SLD Version 0.22
** 
**    Rev 1.4   13 Oct 1995 13:19:42   Shirley
** No change.
** 
**    Rev 1.3   29 Sep 1995 09:53:06   Shirley
** No change.
** 
**    Rev 1.2   20 Sep 1995 10:54:06   Shirley
** No change.
** 
**    Rev 1.1   15 Sep 1995 09:45:32   Shirley
** EasyPack/SLDV0.1a 
** 
**    Rev 1.0   07 Sep 1995 09:55:36   Shirley
** Initial revision.
**
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name:  DSMEDIT1.CPP
//
//  Description:The implement file for the class: CDsmEdit1
//
//  Author:     Lane Li		&		Daniel Lin
//
//  Date:       09/10/95
//
//  Modification:
//               
//		1. 10/25/95, 0.1d version  
//					modified function	OnDsmedit1Button1()
//										OnDsmedit1Button2()
//      1. 09/10/95, Initial version
//
//
//  Copyright (C) 1995 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////

// dsmedit1.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "xview.h"
#include "dsmedit1.h"
#include "address.h"
#include "uicom.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

//extern int MemServerFill(long,BYTE,int);
extern void MemServerFill(ADDRESS Start, ADDRESS End, char* szPattern);

/////////////////////////////////////////////////////////////////////////////
// CDsmEdit1 dialog


CDsmEdit1::CDsmEdit1(CWnd* pParent /*=NULL*/)
    : CDialog(CDsmEdit1::IDD, pParent)
{
    //{{AFX_DATA_INIT(CDsmEdit1)
        // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    m_pParent = pParent;
}

void CDsmEdit1::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CDsmEdit1)
        // NOTE: the ClassWizard will add DDX and DDV calls here
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDsmEdit1, CDialog)
    //{{AFX_MSG_MAP(CDsmEdit1)
    ON_BN_CLICKED(IDC_DSMEDIT1_BUTTON1, OnDsmedit1Button1)
    ON_BN_CLICKED(IDC_DSMEDIT1_BUTTON2, OnDsmedit1Button2)
    ON_BN_CLICKED(IDC_DSMEDIT1_BUTTON3, OnDsmedit1Button3)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CDsmEdit1 message handlers

BOOL CDsmEdit1::OnInitDialog()
{
    CDialog::OnInitDialog();
    CenterWindow();
    
    // TODO: Add extra initialization here
    char text[20];
    CWnd* ctrl;
    
    sprintf(text,"%04lX",m_lAddress);
    SetDlgItemText(IDC_DSMEDIT1_EDIT1,text);
    
    ctrl=GetDlgItem(IDC_DSMEDIT1_EDIT2);
    ctrl->SetFocus();
    
    return FALSE;  // return TRUE  unless you set the focus to a control
}

void CDsmEdit1::OnDsmedit1Button1()
{
    // TODO: Add your control notification handler code here
    char text[20];
    char text2[20];
    long l;
    BYTE b;
    int i;
    BOOL bOk;
    
    bOk = TRUE;
    
    GetDlgItemText(IDC_DSMEDIT1_EDIT2,text,4);
    l = strtol(text,NULL,16);
    if ((text[0]=='0') && (strlen(text)==2)) 
       sprintf(text2,"%02lX",l);
    else sprintf(text2,"%lX",l);
    if (_stricmp(text,text2)!=0)
        bOk=FALSE;
    i = strlen(text);
    if ((i<=0)||(i>2))
        bOk=FALSE;
    if (!bOk)
    {
        MessageBeep(-1);
        MessageBox("Input Error",NULL,MB_OK|MB_ICONEXCLAMATION);        
        return;
    }

    b = (BYTE)l;   
	text[3] = '\0';    
    //MemServerFill(m_lAddress,b,m_nSpaceType);
    ADDRESS adr1, adr2;
    adr1.adrSpace=adr2.adrSpace=(::ADDR_SPACE)m_nSpaceType;
    adr1.adrAddress=m_lAddress;
    adr2.adrAddress=m_lAddress;
    MemServerFill (adr1, adr2, text);
    EndDialog(1);
}

void CDsmEdit1::OnDsmedit1Button2()
{
    // TODO: Add your control notification handler code here
    char text[20];
    char text2[20];
    long l;
    BYTE b;
    int i;
    BOOL bOk;
    
    bOk = TRUE;
    
    GetDlgItemText(IDC_DSMEDIT1_EDIT2,text,4);
    l = strtol(text,NULL,16);
    if ((text[0]=='0')&&(strlen(text)==2)) sprintf(text2,"%02lX",l);
    else sprintf(text2,"%lX",l);
    if (_stricmp(text,text2)!=0)
        bOk=FALSE;
    i = strlen(text);
    if ((i<=0)||(i>2))
        bOk=FALSE;
    if (!bOk)
    {
        MessageBeep(-1); 
        MessageBox("Input Error",NULL,MB_OK|MB_ICONEXCLAMATION);                
        return;
    }
    
    b = (BYTE)l;
    //MemServerFill(m_lAddress,b,m_nSpaceType);
    text[3] = '\0';
	ADDRESS adr1, adr2;
    adr1.adrSpace=adr2.adrSpace=(::ADDR_SPACE)m_nSpaceType;
    adr1.adrAddress=m_lAddress;
    adr2.adrAddress=m_lAddress;
    MemServerFill (adr1, adr2, text);
    //modify by chris, 3/31/97
    //m_pParent->InvalidateRect(NULL,FALSE);
    RepaintMemory();
    RepaintSource();
    m_lAddress++;
    sprintf(text,"%04lX",m_lAddress);
    SetDlgItemText(IDC_DSMEDIT1_EDIT1,text);
    SetDlgItemText(IDC_DSMEDIT1_EDIT2,"");
}

void CDsmEdit1::OnDsmedit1Button3()
{
    // TODO: Add your control notification handler code here
    EndDialog(0);
}
