//////////////////////////////////////////////// //CFGHexEdit V.1.00 //Programma realizzato da Francesco Germinara //www.germinara.it 2005 FREEWARE //info@germinara.it //http://www.germinara.it //programmatore PINEROLO TORINO ITALIA //Data realizzazione: 10/luglio/2005 //////////////////////////////////////////////// // // Thanks to Eugene Pavlov (http://www.softerra.com) for the good job on the // ACTIVEX HEX EDIT CONTRON. // // Some Method are taken from Eugene Pavlov source code. // // CFGHexEdit.cpp : implementation file // #if !defined(AFX_CFGHEXEDIT_H__CD771B2B_3719_473D_91CB_4AD72A97A6B6__INCLUDED_) #define AFX_CFGHEXEDIT_H__CD771B2B_3719_473D_91CB_4AD72A97A6B6__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // CFGHexEdit.h : header file // ///////////////////////////////////////////////////////////////////////////// // CFGHexEdit window class CFGHexEdit : public CEdit { // Construction public: CFGHexEdit(); CString m_strWindowClass; //The registred class CByteArray m_data; //The Data Buffer (HEX VALUE) ever as BYTE short m_bytesInAddress; // 2,4 or 8 Bytes view in Address short m_bytesInData; // 2,4 or 8 Bytes view in Data DWORD m_nStartAddress; //Start Address short int m_columns; //Number of columns int m_fontHeight; //Font Height COLORREF bkColor; //Window background color COLORREF bkTextColor;//Text background color COLORREF bkTextAsciiColor; ////Text background color for ASCII data COLORREF fgTextAsciiColor; //Text foreground color for ASCII data COLORREF bkTextHexColor; //Text background color for HEX data COLORREF fgTextHexColor; //Text foreground color for HEX data int posXAddress; //Start Column position for address int posXHexValue; //Start Column position for hex data int posXDecValue; //Start Column position for dec data int nRow; //Data Row CSize m_cellSize; //Edit Cell Size CSize m_charInWindow;//Numer of row and columns allowed CPoint m_viewPos; //View Position bool m_bMouseDown; // True after WM_LBUTTONDOWN, false after WM_LBUTTONUP bool m_bMouseMove; // True after WM_MOUSEMOVE, false after WM_LBUTTONUP int m_posMouseDown; // Address of number under mouse cursor in WM_LBUTTONDOWN CPoint m_prevMousePoint; //Last Mouse Position bool m_bTimer; //The scroll timer is active long m_selStart; //Initial selection position long m_selEnd; //End of selection position long m_currentEditPosition; //Current edit position int m_nEditType; //0=Hex 1=Dec int m_nNowEditDigit; //Hex Digit Editing BYTE m_selectedBYTE; //Selected Byte Value CString m_strDest; //File Name // Attributes public: // Operations public: CString GetAddrFmt(); //Get Address Formatted CString GetDataFmt(int nDataRow); //Get Data Formatted CString GetDataFmtDec(int nDataRow); //Get Data Formatted Dec void RecalcLayout(); //Recalc Layout of window editor bool UpdateScrollBars(); //Update Scroll Bar Info int GetNumberOfRows(); //Number of row for data rapresentation bool IsSelectionEmpty(); //True if selection in empty void ClearSelection(); //Clear Selection void CalculateEditPosition(CPoint pt); //Calculate new edit position void SetCaretPosition(); //Set Caret Position void RecalcSelection(CPoint point); //Recalculate Position BYTE GetByteFromEditPosition(); //Return Byte Value by current edit position CString GetDataFmtSingleByte(int nDataRow,int nIndexByte,int& nPosBuffer); //Get Data Formatted single Byte void ChangeEditPos(long dx, long dy, bool bRepaint = false ); //Move cursor on edit field int GetIndexFromEditPosition(); //Return Index of Byte Value by current edit position void Initialize(); //Called after create to force the focus void DeleteDataInSelection(); //Delete data value for selected bytes void SetFFDataInSelection(); //Set FF if press INS when a selection was active CString BinaryRapresentation(); //Display Binary Data void SetData(CByteArray& theData); //Set the data to display CByteArray& GetData(); //Get the edit data void SetAllDataValue(BYTE byteValue); //Set all data value to a byte value BOOL Create(CRect rcSize,CWnd *pParent,int edtID); //Create the window void NeedToScroll(); //Check if the cursor is out of the visible area, then scroll void SetColorScheme(COLORREF clrForeWnd,COLORREF clrBackWnd,COLORREF clrForeHex,COLORREF clrBackHex,COLORREF clrForeASCII,COLORREF clrBackACII); //Set Colors scheme void OnLoadFile(); //Display Open File Dilaog for Load data from file void OnSaveFile(); //Display Save File Dilaog for Save data to file void ReadFile(CString m_strDest);//Load data from file void WriteFile(CString m_strDest);//Save data from file // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CFGHexEdit) protected: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); //}}AFX_VIRTUAL // Implementation public: virtual ~CFGHexEdit(); // Generated message map functions protected: //{{AFX_MSG(CFGHexEdit) afx_msg void OnPaint(); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg void OnTimer(UINT nIDEvent); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg UINT OnGetDlgCode(); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/); }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_CFGHEXEDIT_H__CD771B2B_3719_473D_91CB_4AD72A97A6B6__INCLUDED_)