⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hexeditbase.h

📁 EZ-USB 开发板完整资料
💻 H
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////
// Definition
//-------------------------------------------------------------------------
// File........................hexeditbase.h
// Version.....................1.1.0.0
// Autor(s)....................Ch. Kuendig / kuendigc@spectraweb.ch
// Operating system(s).........Windows NT/2000/[95?/98?]
// Compiler(s).................MS VC++, SP3, SP5
//-------------------------------------------------------------------------
// CHexEditBase is a Hex-Edit-Control based on MFC and the CWnd class.
// It implements basic behavior to edit/view Data in hexadecimal view 
// (binary). It's been a fast implementation and it's not that carefully
// designed and as a result of that it doesn't support all the features
// one can dream of. Scrolling is a little slow with slow computers because
// basiacally the whole control is redrawn instead of bitblittering parts
// of the existing control.
//
// Features:
// - multi- / singleline (depending on the windows-style)
// - automatical scrolling when multiline
// - horizontal scrolling without scrollbars when singleline
// - show Address (on/off)
// - variable Address-Size 
// - show Binary (on/off)
// - cursor navigation (arrows, home, end, page up/down)
// - copy/paste (ctrl + c / ctrl + v)
// - context menue (copy / paste)
//   --> strings from resources, when defined: IDS_CONTROL_COPY, IDS_CONTROL_PASTE
// - edit (only hex-data, not binary)
// - selection (only hex-data)
// - special highlighting of a section (not selection)
// - show selection always (only multiline mode)
// - set how many bytes per row or let it calculate (automatic)
// - set colours (every colour can be set)
//   - address: text & background
//   - hexdata: 
//	   - normal: text, background
//     - selected & focus: text & background
//     - selected & no focus: text & background
//	   - highlighted section: text, background and frame (border)
//   - bindata: text & background
//   - unused area (window-background)
// - set readonly (enabled/disabled: no colour-difference) 
//   (derive from CHexEditBase and override SetReadonly: change colours there)
//
// Basic Instructions:
// - Use folowing Code in the InitInstance:
//	 AfxOleInit();
//	 CHexEditBase::RegisterClass();	 (when using the CHexEditBase_SC windows-class)
// - Use the view or/and the control (depending on project)
// - Using the view is bloody simple (check the demo-project: HexEditCtrl)
// - Using the control is easy as well (easiest way:)
//   - Edit the dialogresource and insert edit-controls where you want 
//     to see the hex-control later. Set multiline-flag when you want to 
//     use the control as a multiline.
//   - Use the ClassWizard to connect a member-variable (control (NOT value))
//     with the previously inserted edit-control. (Give class CEdit first)
//   - When this is done, use the code editor and replace the CEdit (int the h-file)
//     with CHexEditBase. Don't forget to include "hexeditbase.h" there.
//	 - Go to the InitDialog (or insert it) and use the m_HexEdit (or how ever your
//     member is called) to set data: m_HexEdit.SetData((BYTE*)"dummydata", 9);
//   - Use other members to set other attributes (set bUbdate (usually last parameter for set-methodes)
//     only with the last SetXXXXX-Methode:
//	   (example for use in a view-class derived from CHexEditBaseView)
//	   GetHexEditCtrl().SetAddressSize(4, false);
//	   GetHexEditCtrl().SetShowAddress(true, false);
//     GetHexEditCtrl().SetShowAscii(true, false);
//     GetHexEditCtrl().SetBytesPerRow(16, true, true);
//
// Legal Notices:
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is 
// not sold for profit without the authors written consent, and 
// providing that this notice and the authors name and all copyright 
// notices remains intact. 
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage/loss of business that
// this product may cause.
// 
// How much time I'll put into maintaining this control depends highly
// on the feedback/help/support I get from people using this control.
// People modifiying and improving this component are asked to send me
// the new source-code. 
// Coordination for extending the control would be nice, so we don't
// land up with 20 differnt hex-controls where none is really working.
//
//
// 
// greetings goes to
// - Maarten Hoeben for his great CReportCtrl & legal notices
//-------------------------------------------------------------------------
// dependencies on libraries and frameworks:
//
// Name            | Version | Description
//-----------------+---------+---------------------------------------------
// MFC             | 4.2     | Microsoft Foundation Classes
//-----------------+---------+---------------------------------------------
//                 |         | 
//-----------------+---------+---------------------------------------------
//                 |         | 
//-----------------+---------+---------------------------------------------
//                 |         | 
//-----------------+---------+---------------------------------------------
//
//
///////////////////////////////////////////////////////////////////////////
// history:
//
// date	     | signature | descritpion of modification
//-----------+-----------+-------------------------------------------------
// 11.01.01  | kuendig   | version 0.0.0.1 
//           |           | - first test version
//-----------+-----------+-------------------------------------------------
// 13.01.01  | kuendig   | version 0.0.0.2 
//           |           | - context menue 
//           |           |   use OnExtendContextMenu to extend the 
//           |           |   context menue in a derived class
//           |           | - paste methode
//           |           | - Windows-Class registering
//           |           |   - CHexEditBase: for use with DDX / Edit-Control
//           |           |   - CHexEditBase_SC: when not using DDX
//           |           | - several small changes
//-----------+-----------+-------------------------------------------------
// 19.01.01  | kuendig   | version 0.0.0.3
//           |           | - bug in CreateHighlightingPolygons
//           |           |   (when scrolling highlighting out of window on 
//           |           |   top, sometimes the address got overpainted
//           |           |   by some parts of the highlighting section)
//-----------+-----------+-------------------------------------------------
// 04.02.01  | kuendig   | version 1.0.0.0 (official release)
//           |           | - MakeVisible is now smarter
//           |           | - SetFont, GetFont WM_SETFONT, WM_GETFONT works now
//-----------+-----------+-------------------------------------------------
// 24.05.01  | kuendig   | version 1.1.0.0
//           |           | - Fixed the 16Bit Scrollrange limitation when
//           |           |   thumbtracking (see OnVScroll)
//           |           | - Modified SetFont to only accept fixed-pitched
//           |           |   fonts
//           |           | - Replaced some GetSafeHwnd() with 
//           |           |   ::IsWindow(m_hWnd), since it's rather what's
//           |           |   beeing checked. (Even when GetSafeHwnd worked
//           |           |   in most of the cases)
//           |           | - Call DestroyWnd from the Destructor, to get
//           |           |   rid of the TRACE from "CWnd::~CWnd ..."
//-----------+-----------+-------------------------------------------------
// --.--.--  |           | 
//-----------+-----------+-------------------------------------------------
// --.--.--  |           | 
//-----------+-----------+-------------------------------------------------
// --.--.--  |           | 
//-----------+-----------+-------------------------------------------------
// --.--.--  |           | 
//-----------+-----------+-------------------------------------------------
// --.--.--  |           | 
//-----------+-----------+-------------------------------------------------
// --.--.--  |           | 
//-----------+-----------+-------------------------------------------------
// --.--.--  |           | 
//-----------+-----------+-------------------------------------------------
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
#ifndef __hexeditbase_h
#define __hexeditbase_h
#if _MSC_VER > 1000
#pragma once
#endif


/////////////////////////////////////////////////////////////////////////////
// defines
/////////////////////////////////////////////////////////////////////////////
#define NOSECTION_VAL				0xffffffff

// notification codes
#define HEN_CHANGE					EN_CHANGE	//the same as the EDIT (CEdit)


/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// class CHexEditBase
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////

class CHexEditBase : public CWnd
{
public:
	CHexEditBase();
	virtual ~CHexEditBase();
	void SetShowAddress(bool bShow, bool bUpdate = true);
	void SetShowAscii(bool bShow, bool bUpdate = true);
	void SetInputAscii(bool bInputAscii, bool bUpdate = true);
	void SetData(const BYTE *pData, UINT nLen, bool bUpdate = true);
	void SetDirectDataPtr(BYTE *pData, UINT nLen, bool bUpdate = true); // won't copy data and won't free memory
	void SetHighlighted(UINT nBegin, UINT nEnd, bool bMakeVisible = true, bool bUpdate = true);
	void SetSelection(UINT nBegin, UINT nEnd, bool bMakeVisible = true, bool bUpdate = true);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -