#if !defined(AFX_DATAEDITCTRL_H__5316BBD1_0EA4_11D5_980E_00AA00BA4C4D__INCLUDED_)
#define AFX_DATAEDITCTRL_H__5316BBD1_0EA4_11D5_980E_00AA00BA4C4D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class _AFX_RICHEDITEX_STATE
{
	public:
			 _AFX_RICHEDITEX_STATE() ;
	virtual ~_AFX_RICHEDITEX_STATE() ;

	public:
	HINSTANCE m_hInstRichEdit20 ;
};

/////////////////////////////////////////////////////////////////////////////
// CHexEditCtrl window

#define	MAX_HEX_DATA	25500

class CHexEditCtrl : public CRichEditCtrl
{
// Construction
public:
	CHexEditCtrl();

	BOOL Create(DWORD in_dwStyle,  const RECT& in_rcRect,
                             CWnd* in_pParentWnd, UINT in_nID);

// Attributes
public:
	enum DataMode { TEXT_MODE = 0, HEX_MODE };

private:
	DataMode m_DataMode;
	CFont m_Font;
	CString m_Data;
	long m_nDataLength;
	TCHAR m_chBinaryChar;
	BOOL m_bIsDataChangedDisabled;
	static BOOL m_bInitCalled;

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CHexEditCtrl)
	public:
	protected:
	//}}AFX_VIRTUAL

// Implementation
public:
	void SetBinaryCharacter(TCHAR ch);
	
	virtual void SetDataSelection(const long nFirst, const long nLength);
	
	void DataToScreen();
	void SetData(CString Data, long nLength);
	void GetData(CString& Data, const long nMaxLength, long& nLengthReturned);

	void SetDataMode(const DataMode& mode);

	BOOL IsDataChanged();	// only tests data changed since the last call to this function
private:
	void ConvertHexToData(const CString &sHex);
	CString ConvertCharToHex(CString pData, long nDataLength);
	TCHAR hex2int (CString hex);

	CString m_OldData;
	long m_nOldDataLength;


  virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);

	// Generated message map functions
protected:
	//{{AFX_MSG(CHexEditCtrl)
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DATAEDITCTRL_H__5316BBD1_0EA4_11D5_980E_00AA00BA4C4D__INCLUDED_)
